forked from XeroAPI/xero-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
taxrates.integration.tests.ts
50 lines (43 loc) · 1.41 KB
/
taxrates.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
import { TaxRate } from '../AccountingAPI-models';
import { TaxRatesResponse } from '../AccountingAPI-responses';
import { AccountingAPIClient } from '../AccountingAPIClient';
import { getPrivateConfig, setJestTimeout } from './helpers/integration.helpers';
describe('/taxrates', () => {
let xero: AccountingAPIClient;
beforeAll(async () => {
setJestTimeout();
const config = getPrivateConfig();
xero = new AccountingAPIClient(config);
});
it('update', async () => {
const rate: TaxRate = {
Name: 'Node Tax',
TaxType: 'INPUT',
ReportTaxType: 'INPUT',
TaxComponents: [{
Name: 'Tech Debt Tax',
Rate: 17.5,
IsCompound: false,
IsNonRecoverable: false
}]
};
expect.assertions(2);
let response: TaxRatesResponse;
try {
response = await xero.taxRates.update(rate);
expect(response.TaxRates).toBeInstanceOf(Array);
expect(response.TaxRates[0]).toHaveProperty('Name', 'Node Tax');
} catch (err) {
// updating fails in Circle so we'll just check its a validation error
expect(err.statusCode).toBe(400);
expect(err.statusCode).toBe(400);
}
});
it('get all', async () => {
const response = await xero.taxRates.get();
expect(response).not.toBeNull();
expect(response.TaxRates).toBeInstanceOf(Array);
expect(response.TaxRates[0]).toHaveProperty('Name');
expect(response.TaxRates[0]).toHaveProperty('TaxType');
});
});