forked from Gainsight/integrations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.preact.js
82 lines (64 loc) · 2.31 KB
/
test.preact.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
77
78
79
80
81
82
var auth = require('./auth')
, facade = require('segmentio-facade')
, helpers = require('./helpers')
, integrations = require('..')
, should = require('should');
var preact = new integrations['Preact']()
, settings = auth['Preact'];
describe('Preact', function () {
describe('.enabled()', function () {
it('should only be enabled for server side messages', function () {
preact.enabled(new facade.Track({
userId: '[email protected]',
channel: 'server'
})).should.be.ok;
preact.enabled(new facade.Track({
userId: '[email protected]',
channel: 'client'
})).should.not.be.ok;
preact.enabled(new facade.Track({
userId: '[email protected]'
})).should.not.be.ok;
});
it('should only be enabled for messages with an email', function () {
preact.enabled(new facade.Track({
userId: '[email protected]',
channel: 'server'
})).should.be.ok;
preact.enabled(new facade.Track({
channel: 'server'
}));
});
});
describe('.validate()', function () {
it('should require a projectCode', function () {
preact.validate({}, { projectCode : '' }).should.be.an.instanceOf(Error);
preact.validate({}, { projectCode : '', apiSecret : 'xxx' }).should.be.an.instanceOf(Error);
});
it('should require an apiSecret', function () {
preact.validate({}, { apiSecret : '' }).should.be.an.instanceOf(Error);
preact.validate({}, { apiSecret : '', projectCode : 'xxx' }).should.be.an.instanceOf(Error);
});
it('should validate with the required settings', function () {
should.not.exist(preact.validate({}, { projectCode : 'xxx', apiSecret : 'xxx' }));
});
});
describe('.track()', function () {
it('should get a good response from the API', function (done) {
var track = helpers.track();
preact.track(track, settings, done);
});
});
describe('.identify()', function () {
var identify = helpers.identify();
it('should be able to identify correctly', function (done) {
preact.identify(identify, settings, done);
});
});
describe('.alias()', function () {
it('should do nothing', function (done) {
var alias = helpers.alias();
preact.alias(alias, settings, done);
});
});
});