-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathanalytics.test.js
34 lines (28 loc) · 973 Bytes
/
analytics.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
const testWithServer = require('./helpers/test-with-server');
const file = require('path').relative(process.cwd(), __filename) + ' > ';
testWithServer(file + 'Should process RESULT_CLICK analytics event', {}, async (t, ctx) => {
t.plan(1);
const request = {
method: 'POST',
url: '/analytics',
headers: {
Accept: 'application/vnd.api+json',
'Content-Type': 'application/json'
},
payload: JSON.stringify({ event: 'RESULT_CLICK', data: 'smg-objects-12345' })
};
const res = await ctx.server.inject(request);
t.equal(res.statusCode, 204, 'Status was OK');
t.end();
});
testWithServer(file + 'empty response if not a json request', {}, async (t, ctx) => {
t.plan(1);
const request = {
method: 'POST',
url: '/analytics',
payload: JSON.stringify({ event: 'RESULT_CLICK', data: 'smg-objects-12345' })
};
const res = await ctx.server.inject(request);
t.equal(res.statusCode, 204, 'No content');
t.end();
});