1 | var Mixpanel = require('../lib/mixpanel-node');
|
2 |
|
3 | exports.config = {
|
4 | setUp: function(cb) {
|
5 | this.mixpanel = Mixpanel.init('asjdf');
|
6 | cb();
|
7 | },
|
8 |
|
9 | "is set to correct defaults": function(test) {
|
10 | test.deepEqual(this.mixpanel.config, {
|
11 | test: false,
|
12 | debug: false,
|
13 | verbose: false,
|
14 | host: 'api.mixpanel.com',
|
15 | protocol: 'https',
|
16 | path: '',
|
17 | keepAlive: true,
|
18 | geolocate: false,
|
19 | }, "default config is incorrect");
|
20 | test.done();
|
21 | },
|
22 |
|
23 | "is modified by set_config": function(test) {
|
24 | test.equal(this.mixpanel.config.test, false, "default config has incorrect value for test");
|
25 |
|
26 | this.mixpanel.set_config({ test: true });
|
27 |
|
28 | test.equal(this.mixpanel.config.test, true, "set_config failed to modify the config");
|
29 |
|
30 | test.done();
|
31 | },
|
32 |
|
33 | "can be set during init": function(test) {
|
34 | var mp = Mixpanel.init('token', { test: true });
|
35 |
|
36 | test.equal(mp.config.test, true, "init() didn't set the config correctly");
|
37 | test.done();
|
38 | },
|
39 |
|
40 | "host config is split into host and port": function(test) {
|
41 | const exampleHost = 'api.example.com';
|
42 | const examplePort = 70;
|
43 | const hostWithoutPortConfig = Mixpanel.init('token', {host: exampleHost}).config;
|
44 | test.equal(hostWithoutPortConfig.port, undefined, "port should not have been added to config");
|
45 | test.equal(hostWithoutPortConfig.host, exampleHost, `host should match ${exampleHost}`);
|
46 |
|
47 | const hostWithPortConfig = Mixpanel.init('token', {host: `${exampleHost}:${examplePort}`}).config;
|
48 | test.equal(hostWithPortConfig.port, examplePort, "port should have been added to config");
|
49 | test.equal(hostWithPortConfig.host, exampleHost, `host should match ${exampleHost}`);
|
50 |
|
51 | test.done();
|
52 | },
|
53 | };
|