forked from Nova-reward/Nova-Rewards
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransactionRepositoryNullableCampaignId.test.js
More file actions
42 lines (36 loc) · 1.07 KB
/
Copy pathtransactionRepositoryNullableCampaignId.test.js
File metadata and controls
42 lines (36 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
jest.mock('../db/index', () => ({ query: jest.fn() }));
const { query } = require('../db/index');
const { recordTransaction } = require('../db/transactionRepository');
describe('recordTransaction campaignId nullability', () => {
beforeEach(() => {
jest.clearAllMocks();
query.mockResolvedValue({ rows: [{ id: 1 }] });
});
test('passes SQL null at $7 when campaignId is undefined', async () => {
await recordTransaction({
txHash: 'abc123',
txType: 'distribution',
amount: '10',
fromWallet: 'GAAAA',
toWallet: 'GBBBB',
merchantId: 1,
stellarLedger: 123,
});
const params = query.mock.calls[0][1];
expect(params[6]).toBeNull();
});
test('passes SQL null at $7 when campaignId is null', async () => {
await recordTransaction({
txHash: 'def456',
txType: 'distribution',
amount: '20',
fromWallet: 'GCCCC',
toWallet: 'GDDDD',
merchantId: 2,
campaignId: null,
stellarLedger: 456,
});
const params = query.mock.calls[0][1];
expect(params[6]).toBeNull();
});
});