-
Notifications
You must be signed in to change notification settings - Fork 539
/
Copy pathhelper.insights.js
42 lines (31 loc) · 1.08 KB
/
helper.insights.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
'use strict';
jest.retryTimes(3, { logErrorsBeforeRetry: true });
var utils = require('../../test/integration-utils');
var setup = utils.setupSimple;
var createIndexName = utils.createIndexName;
var algoliasearchHelper = require('../../');
var indexName = createIndexName('helper_insights');
var dataset = [{ objectID: '1', name: 'TestName' }];
var config = {};
var client;
beforeAll(function () {
return setup(indexName, dataset, config).then(function (c) {
client = c;
});
});
test('[INT][INSIGHTS] search with clickAnalytics should have a queryID', function (done) {
var helper = algoliasearchHelper(client, indexName, { clickAnalytics: true });
helper.on('result', function (event) {
expect(event.results.queryID).toEqual(expect.any(String));
done();
});
helper.search();
});
test('[INT][INSIGHTS] search without clickAnalytics should not have a queryID', function (done) {
var helper = algoliasearchHelper(client, indexName, {});
helper.on('result', function (event) {
expect(event.results.queryID).toBeUndefined();
done();
});
helper.search();
});