* Drives `db.select().from().where()` results in call order. Both an awaited * `where()` and a chained `.limit()` resolve to the same per-call value.
(responses: unknown[][])
| 57 | * `where()` and a chained `.limit()` resolve to the same per-call value. |
| 58 | */ |
| 59 | function queueWhereResponses(responses: unknown[][]) { |
| 60 | const queue = [...responses] |
| 61 | dbChainMockFns.where.mockImplementation(() => { |
| 62 | const result = queue.shift() ?? [] |
| 63 | const thenable = Promise.resolve(result) as Promise<unknown[]> & { |
| 64 | limit: ReturnType<typeof vi.fn> |
| 65 | orderBy: ReturnType<typeof vi.fn> |
| 66 | returning: ReturnType<typeof vi.fn> |
| 67 | groupBy: ReturnType<typeof vi.fn> |
| 68 | } |
| 69 | thenable.limit = vi.fn(() => Promise.resolve(result)) |
| 70 | thenable.orderBy = vi.fn(() => Promise.resolve(result)) |
| 71 | thenable.returning = vi.fn(() => Promise.resolve(result)) |
| 72 | thenable.groupBy = vi.fn(() => Promise.resolve(result)) |
| 73 | return thenable as ReturnType<typeof dbChainMockFns.where> |
| 74 | }) |
| 75 | } |
| 76 | |
| 77 | const baseInput = { |
| 78 | userId: 'user-2', |
no test coverage detected