Flattens nested and/or condition trees from the drizzle operator mocks.
(condition: unknown)
| 58 | |
| 59 | /** Flattens nested and/or condition trees from the drizzle operator mocks. */ |
| 60 | function flattenCondition(condition: unknown): unknown[] { |
| 61 | if (!condition || typeof condition !== 'object') return [] |
| 62 | const node = condition as { type?: string; conditions?: unknown[] } |
| 63 | if (node.type === 'and' || node.type === 'or') { |
| 64 | return [node, ...(node.conditions ?? []).flatMap(flattenCondition)] |
| 65 | } |
| 66 | return [node] |
| 67 | } |
| 68 | |
| 69 | function allWhereConditions(): unknown[] { |
| 70 | return dbChainMockFns.where.mock.calls.flatMap(([condition]) => flattenCondition(condition)) |
no outgoing calls
no test coverage detected