-
Notifications
You must be signed in to change notification settings - Fork 12
/
test.js
76 lines (59 loc) · 1.81 KB
/
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
65
66
67
68
69
70
71
72
73
74
75
76
require('cross-fetch/polyfill');
const apiClient = require('./dist/cjs/index');
const dotenv = require('dotenv');
dotenv.config();
const START_AT = 1682924400000;
const END_AT = 1696143599999;
describe('Testing all get functions', () => {
beforeAll(() => {
apiClient.client = apiClient.getClient();
});
async function testGetWebsites() {
const results = await apiClient.client.getWebsites();
return results.ok;
}
test('Testing: getWebsites', () => {
return expect(testGetWebsites()).resolves.toBeTruthy();
});
async function testGetMe() {
const results = await apiClient.client.getMe();
return results.ok;
}
test('Testing: getMe', () => {
return expect(testGetMe()).resolves.toBeTruthy();
});
async function testGetWebsiteMetrics() {
const results = await apiClient.client.getWebsiteMetrics(process.env.UMAMI_WEBSITE_ID, {
startAt: START_AT,
endAt: END_AT,
type: 'url',
});
return results.ok;
}
test('Testing: getWebsiteMetrics', () => {
return expect(testGetWebsiteMetrics()).resolves.toBeTruthy();
});
async function testGetWebsitePageviews() {
const results = await apiClient.client.getWebsitePageviews(process.env.UMAMI_WEBSITE_ID, {
startAt: START_AT,
endAt: END_AT,
url: '/',
timezone: 'America/Los_Angeles',
});
return results.ok;
}
test('Testing: getWebsitePageviews', () => {
return expect(testGetWebsitePageviews()).resolves.toBeTruthy();
});
async function testGetWebsitesStats() {
const results = await apiClient.client.getWebsiteStats(process.env.UMAMI_WEBSITE_ID, {
startAt: START_AT,
endAt: END_AT,
url: '/',
});
return results.ok;
}
test('Testing: getWebsitesStats', () => {
return expect(testGetWebsitesStats()).resolves.toBeTruthy();
});
});