(rowCount = 1)
| 106 | |
| 107 | describe('.upsert', () => { |
| 108 | function makeFakeQueryBuilder(rowCount = 1) { |
| 109 | const fakeQB = { |
| 110 | then: (fn: (v: any) => any) => Promise.resolve({ rowCount }).then(fn), |
| 111 | catch: (fn: (e: any) => any) => Promise.resolve(rowCount).catch(fn), |
| 112 | toString: () => 'fake', |
| 113 | } |
| 114 | const mergeStub = sandbox.stub().returns(fakeQB) |
| 115 | const onConflictStub = sandbox.stub().returns({ merge: mergeStub }) |
| 116 | const insertStub = sandbox.stub().returns({ onConflict: onConflictStub }) |
| 117 | const client = sandbox.stub().returns({ insert: insertStub }) as unknown as DatabaseClient |
| 118 | return { client, insertStub, onConflictStub, mergeStub } |
| 119 | } |
| 120 | |
| 121 | it('resolves with the row count from the DB response', async () => { |
| 122 | const { client } = makeFakeQueryBuilder(1) |
no outgoing calls
no test coverage detected