-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplugin.test.js
44 lines (38 loc) · 886 Bytes
/
plugin.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
import TelegrafGA4 from './src/esm/index.mjs';
import dotenv from 'dotenv';
dotenv.config();
const config = {
measurement_id: process.env.GA_MEASUREMENT_ID,
api_secret: process.env.GA_API_SECRET,
client_id: process.env.GA_CLIENT_ID,
}
const analytics = new TelegrafGA4(config);
const events = [
{
name: 'share',
params: {
method: 'Telegram'
}
},
{
name: 'sign_up',
params: {
method: 'Telegram'
}
}
];
test('sends a debug event and returns an empty array on success', (done) => {
analytics.event('login', {
method: 'login'
}, true).then(result => {
expect(result).toStrictEqual([]);
done();
});
});
test('sends debug events and returns an empty array on success', (done) => {
analytics.events(events, true).then(result => {
expect(result).toStrictEqual([]);
done();
});
});
afterAll(done => done());