forked from kriskbx/gitlab-time-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.spec.js
More file actions
executable file
·52 lines (39 loc) · 1.47 KB
/
config.spec.js
File metadata and controls
executable file
·52 lines (39 loc) · 1.47 KB
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
const config = require('./../../src/include/config');
const expect = require('chai').expect;
describe('The config class', () => {
it('stores data', () => {
let Config = new config(),
data = 'value_' + Math.random(),
key = 'key_' + Math.random();
Config.set(key, data);
expect(Config.get(key)).to.equal(data);
});
it('doesnt store data if the value is null or undefined until you force it', () => {
let Config = new config(),
data = 'value_' + Math.random(),
key = 'key_' + Math.random();
Config.set(key, data);
Config.set(key, null);
expect(Config.get(key)).to.equal(data);
Config.set(key, undefined);
expect(Config.get(key)).to.equal(data);
Config.set(key, null, true);
expect(Config.get(key)).to.equal(null);
Config.set(key, undefined, true);
expect(Config.get(key)).to.equal(undefined);
});
it('returns moment instances for dates', () => {
let Config = new config(),
dates = ['from', 'to'];
dates.forEach(date => {
Config.set(date, "2017-08-01");
expect(typeof Config.get(date).format).to.equal("function");
});
});
it('makes durations human readable', () => {
let Config = new config,
humanReadable = "1d 4h 30m 10s",
seconds = 45010;
expect(Config.toHumanReadable(seconds)).to.equal(humanReadable);
});
});