| 36 | })) |
| 37 | |
| 38 | function makeBuilder(rows: any[]): any { |
| 39 | const thenable: any = Promise.resolve(rows) |
| 40 | thenable.where = (condition: any) => { |
| 41 | const values = condition?.values |
| 42 | if (Array.isArray(values) && values.length > 0) { |
| 43 | const target = String(values[values.length - 1]).toLowerCase() |
| 44 | return makeBuilder(rows.filter((r) => String(r.domain ?? '').toLowerCase() === target)) |
| 45 | } |
| 46 | return makeBuilder(rows) |
| 47 | } |
| 48 | thenable.limit = () => Promise.resolve(rows) |
| 49 | thenable.orderBy = () => Promise.resolve(rows) |
| 50 | return thenable |
| 51 | } |
| 52 | |
| 53 | vi.mock('@sim/db', () => ({ |
| 54 | db: { |