forked from XeroAPI/xero-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneric-endpoint.integration.tests.ts
70 lines (52 loc) · 2.24 KB
/
generic-endpoint.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
import { UsersResponse } from '../AccountingAPI-responses';
import { AccountingAPIClient } from '../AccountingAPIClient';
import { BaseAPIClient } from '../internals/BaseAPIClient';
import { getPrivateConfig, setJestTimeout } from './helpers/integration.helpers';
describe('Generic accounting endpoint tests', () => {
let xero: AccountingAPIClient;
let existingId: string;
beforeAll(() => {
setJestTimeout();
const config = getPrivateConfig('1');
xero = new AccountingAPIClient(config);
});
it('get all', async () => {
const response = await xero.oauth1Client.get('users');
expect(response).toBeDefined();
expect((response as UsersResponse).Id).toBeTruthy();
expect((response as UsersResponse).Users.length).toBeGreaterThan(0);
expect((response as UsersResponse).Users[0].UserID).toBeTruthy();
existingId = (response as UsersResponse).Users[0].UserID;
});
it('get single', async () => {
const response = await xero.oauth1Client.get('users?UserID=' + existingId);
expect((response as UsersResponse)).toBeDefined();
expect((response as UsersResponse).Id).toBeTruthy();
expect((response as UsersResponse).Users.length).toBe(1);
expect((response as UsersResponse).Users[0].UserID).toBeTruthy();
});
});
describe('Generic endpoint tests', () => {
let xero: BaseAPIClient;
let existingId: string;
beforeAll(() => {
setJestTimeout();
const config = getPrivateConfig('1');
xero = new BaseAPIClient(config);
});
it('get all', async () => {
const response = await xero.oauth1Client.get('/api.xro/2.0/users');
expect(response).toBeDefined();
expect((response as UsersResponse).Id).toBeTruthy();
expect((response as UsersResponse).Users.length).toBeGreaterThan(0);
expect((response as UsersResponse).Users[0].UserID).toBeTruthy();
existingId = (response as UsersResponse).Users[0].UserID;
});
it('get single', async () => {
const response = await xero.oauth1Client.get('/api.xro/2.0/users?UserID=' + existingId);
expect((response as UsersResponse)).toBeDefined();
expect((response as UsersResponse).Id).toBeTruthy();
expect((response as UsersResponse).Users.length).toBe(1);
expect((response as UsersResponse).Users[0].UserID).toBeTruthy();
});
});