forked from XeroAPI/xero-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manualjournals.integration.tests.ts
60 lines (50 loc) · 2.01 KB
/
manualjournals.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
import { AccountingAPIClient } from '../AccountingAPIClient';
import { getOrCreateManualJournalId } from './helpers/entityId.helpers';
import { getPrivateConfig, setJestTimeout } from './helpers/integration.helpers';
describe('/manualJournals', () => {
let xero: AccountingAPIClient;
beforeAll(() => {
setJestTimeout();
const config = getPrivateConfig();
xero = new AccountingAPIClient(config);
});
it('create single', async () => {
const response = await xero.manualJournals.create({
Narration: 'Accrued expenses - prepaid insurance adjustment for January 2011',
JournalLines: [
{ LineAmount: 55.00, AccountCode: '433' },
{ LineAmount: -55.00, AccountCode: '620' }
]
});
expect(response.ManualJournals.length).toBe(1);
expect(response.ManualJournals[0].StatusAttributeString).toEqual('OK');
});
it('get single', async () => {
const response = await xero.manualJournals.get({ ManualJournalID: await getOrCreateManualJournalId(xero) });
expect(response).toBeDefined();
expect(response.Id).toBeTruthy();
expect(response.ManualJournals.length).toBe(1);
expect(response.ManualJournals[0].ManualJournalID).toBeTruthy();
});
it('get all', async () => {
const response = await xero.manualJournals.get();
expect(response).toBeDefined();
expect(response.Id).toBeTruthy();
expect(response.ManualJournals.length).toBeGreaterThan(0);
expect(response.ManualJournals[0].ManualJournalID).toBeTruthy();
});
it('update', async () => {
const response = await xero.manualJournals.update({
ManualJournalID: await getOrCreateManualJournalId(xero),
JournalLines: [
{ LineAmount: 5.00, AccountCode: '433' },
{ LineAmount: -5.00, AccountCode: '620' }
]
});
expect(response).toBeDefined();
expect(response.Id).toBeTruthy();
expect(response.ManualJournals.length).toBe(1);
expect(response.ManualJournals[0].ManualJournalID).toBeTruthy();
expect(response.ManualJournals[0].StatusAttributeString).toEqual('OK');
});
});