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 | }, "default config is incorrect");
|
19 | test.done();
|
20 | },
|
21 |
|
22 | "is modified by set_config": function(test) {
|
23 | test.equal(this.mixpanel.config.test, false, "default config has incorrect value for test");
|
24 |
|
25 | this.mixpanel.set_config({ test: true });
|
26 |
|
27 | test.equal(this.mixpanel.config.test, true, "set_config failed to modify the config");
|
28 |
|
29 | test.done();
|
30 | },
|
31 |
|
32 | "can be set during init": function(test) {
|
33 | var mp = Mixpanel.init('token', { test: true });
|
34 |
|
35 | test.equal(mp.config.test, true, "init() didn't set the config correctly");
|
36 | test.done();
|
37 | },
|
38 |
|
39 | "host config is split into host and port": function(test) {
|
40 | const exampleHost = 'api.example.com';
|
41 | const examplePort = 70;
|
42 | const hostWithoutPortConfig = Mixpanel.init('token', {host: exampleHost}).config;
|
43 | test.equal(hostWithoutPortConfig.port, undefined, "port should not have been added to config");
|
44 | test.equal(hostWithoutPortConfig.host, exampleHost, `host should match ${exampleHost}`);
|
45 |
|
46 | const hostWithPortConfig = Mixpanel.init('token', {host: `${exampleHost}:${examplePort}`}).config;
|
47 | test.equal(hostWithPortConfig.port, examplePort, "port should have been added to config");
|
48 | test.equal(hostWithPortConfig.host, exampleHost, `host should match ${exampleHost}`);
|
49 |
|
50 | test.done();
|
51 | },
|
52 | };
|