| 50 | } |
| 51 | |
| 52 | const createDbMock = (options?: { |
| 53 | grants?: typeof mockGrants | any[] |
| 54 | insert?: () => { values: () => { onConflictDoNothing: () => { returning: () => Promise<unknown[]> } } } |
| 55 | update?: () => { set: () => { where: () => Promise<unknown> } } |
| 56 | }) => { |
| 57 | const { grants = mockGrants, insert, update } = options ?? {} |
| 58 | |
| 59 | return { |
| 60 | select: () => ({ |
| 61 | from: () => ({ |
| 62 | where: () => ({ |
| 63 | orderBy: () => grants, |
| 64 | }), |
| 65 | }), |
| 66 | }), |
| 67 | insert: |
| 68 | insert ?? |
| 69 | (() => ({ |
| 70 | values: () => ({ |
| 71 | onConflictDoNothing: () => ({ |
| 72 | returning: () => Promise.resolve([{ id: 'test-id' }]), |
| 73 | }), |
| 74 | }), |
| 75 | })), |
| 76 | update: |
| 77 | update ?? |
| 78 | (() => ({ |
| 79 | set: () => ({ |
| 80 | where: () => Promise.resolve(), |
| 81 | }), |
| 82 | })), |
| 83 | execute: () => Promise.resolve([]), |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | describe('Organization Billing', () => { |
| 88 | beforeEach(async () => { |