forked from XeroAPI/xero-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepayments.integration.tests.ts
73 lines (61 loc) · 2.29 KB
/
prepayments.integration.tests.ts
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
65
66
67
68
69
70
71
72
73
import { AccountingAPIClient } from '../AccountingAPIClient';
import { getPrivateConfig, setJestTimeout } from './helpers/integration.helpers';
describe('/prepayments', () => {
let xero: AccountingAPIClient;
let existingId: string;
beforeAll(() => {
setJestTimeout();
const config = getPrivateConfig();
xero = new AccountingAPIClient(config);
});
it('create via banktransactions endpoint', async () => {
const response = await xero.bankTransactions.create({
Type: 'RECEIVE-PREPAYMENT',
Contact: { ContactID: '6d42f03b-181f-43e3-93fb-2025c012de92' },
BankAccount: { Code: '090' },
LineAmountTypes: 'Exclusive',
LineItems: [
{
Description: 'Prepayment for Kitchen Designs',
Quantity: 1,
UnitAmount: 500.00,
AccountCode: '200'
}, {
Description: 'Prepayment for Kitchen materials',
Quantity: 1,
UnitAmount: 1000.00,
AccountCode: '200'
}
]
});
expect(response.BankTransactions.length).toBe(1);
expect(response.BankTransactions[0].BankAccount.Code).toEqual('090');
existingId = response.BankTransactions[0].PrepaymentID;
});
it('get all', async () => {
const response = await xero.prepayments.get();
expect(response).toBeDefined();
expect(response.Id).toBeTruthy();
expect(response.Prepayments.length).toBeGreaterThan(0);
expect(response.Prepayments[0].PrepaymentID).toBeTruthy();
});
it('get single', async () => {
const response = await xero.prepayments.get({ PrepaymentID: existingId });
expect(response).toBeDefined();
expect(response.Id).toBeTruthy();
expect(response.Prepayments.length).toBe(1);
expect(response.Prepayments[0].PrepaymentID).toEqual(existingId);
});
// it('get history', async () => {
// const response = await xero.prepayments.history.get({ PrepaymentID: existingId });
// expect(response.HistoryRecords[0]).toBeDefined();
// });
it('reverse via the payments endpoint', async () => {
const response = await xero.payments.update({ PaymentID: existingId, Status: 'DELETED' });
expect(response).toBeDefined();
expect(response.Id).toBeTruthy();
expect(response.Payments.length).toBe(1);
expect(response.Payments[0].PaymentID).toEqual(existingId);
expect(response.Payments[0].Status).toEqual('DELETED');
});
});