-
Notifications
You must be signed in to change notification settings - Fork 0
/
send-batch.test.js
64 lines (55 loc) · 1.67 KB
/
send-batch.test.js
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const Chance = require('chance');
const sendBatch = require('./send-batch');
const chance = new Chance();
describe('send-batch', () => {
let bt;
beforeEach(() => {
bt = {
tokens: {
list: jest.fn(),
}
}
})
test('generates batch', async () => {
const routingNumber = chance.string({numeric: true});
const accountNumber = chance.string({numeric: true});
const id = chance.guid();
bt.tokens.list.mockResolvedValueOnce({
pagination: {},
data: [{
id,
data: {
routing_number: routingNumber,
account_number: accountNumber
}
}]
});
const {raw: {batch}} = await sendBatch({
bt,
args: {
File: {
'@PaymentCount': 1,
'@PaymentTotal': '1000.00',
Payment: [{
ReceiverAccount: {
token: id,
Account: {
'@AccountType': 'Checking',
Bank: {
'@Type': 'ABA',
'@Name': 'Payee',
}
}
},
Amount: '1000.00',
Currency: 'USD',
Date: '2023-02-06'
}]
}
}
});
expect(bt.tokens.list).toHaveBeenCalledWith({id: [id]});
expect(batch).toStrictEqual(`<?xml version="1.0"?><File PaymentCount="1" PaymentTotal="1000.00"><Payment><ReceiverAccount><Account AccountType="Checking" AccountNumber="${accountNumber}"><Bank Type="ABA" Name="Payee"><RoutingNumber>${routingNumber}</RoutingNumber></Bank></Account></ReceiverAccount><Amount>1000.00</Amount><Currency>USD</Currency><Date>2023-02-06</Date></Payment></File>`);
console.info(batch)
})
})