-
Notifications
You must be signed in to change notification settings - Fork 159
/
config.js
53 lines (42 loc) · 1.83 KB
/
config.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
var Mixpanel = require('../lib/mixpanel-node');
exports.config = {
setUp: function(cb) {
this.mixpanel = Mixpanel.init('asjdf');
cb();
},
"is set to correct defaults": function(test) {
test.deepEqual(this.mixpanel.config, {
test: false,
debug: false,
verbose: false,
host: 'api.mixpanel.com',
protocol: 'https',
path: '',
keepAlive: true,
geolocate: false,
}, "default config is incorrect");
test.done();
},
"is modified by set_config": function(test) {
test.equal(this.mixpanel.config.test, false, "default config has incorrect value for test");
this.mixpanel.set_config({ test: true });
test.equal(this.mixpanel.config.test, true, "set_config failed to modify the config");
test.done();
},
"can be set during init": function(test) {
var mp = Mixpanel.init('token', { test: true });
test.equal(mp.config.test, true, "init() didn't set the config correctly");
test.done();
},
"host config is split into host and port": function(test) {
const exampleHost = 'api.example.com';
const examplePort = 70;
const hostWithoutPortConfig = Mixpanel.init('token', {host: exampleHost}).config;
test.equal(hostWithoutPortConfig.port, undefined, "port should not have been added to config");
test.equal(hostWithoutPortConfig.host, exampleHost, `host should match ${exampleHost}`);
const hostWithPortConfig = Mixpanel.init('token', {host: `${exampleHost}:${examplePort}`}).config;
test.equal(hostWithPortConfig.port, examplePort, "port should have been added to config");
test.equal(hostWithPortConfig.host, exampleHost, `host should match ${exampleHost}`);
test.done();
},
};