Skip to content

Commit d21f330

Browse files
committed
Add first unit test and travis config
1 parent 77862d1 commit d21f330

File tree

4 files changed

+266
-5
lines changed

4 files changed

+266
-5
lines changed

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
language: node_js
2+
node_js:
3+
- "6"
4+
- "6.11"
5+
- "7"
6+
- "8"
7+
cache: yarn

spec/include/config.spec.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
const config = require('./../../src/include/config');
2+
const expect = require('chai').expect;
3+
4+
describe('The config class', () => {
5+
it('stores data', () => {
6+
let Config = new config(),
7+
data = 'value_' + Math.random(),
8+
key = 'key_' + Math.random();
9+
10+
Config.set(key, data);
11+
12+
expect(Config.get(key)).to.equal(data);
13+
});
14+
15+
it('doesnt store data if the value is null or undefined until you force it', () => {
16+
let Config = new config(),
17+
data = 'value_' + Math.random(),
18+
key = 'key_' + Math.random();
19+
20+
Config.set(key, data);
21+
22+
Config.set(key, null);
23+
expect(Config.get(key)).to.equal(data);
24+
25+
Config.set(key, undefined);
26+
expect(Config.get(key)).to.equal(data);
27+
28+
Config.set(key, null, true);
29+
expect(Config.get(key)).to.equal(null);
30+
31+
Config.set(key, undefined, true);
32+
expect(Config.get(key)).to.equal(undefined);
33+
});
34+
35+
it('returns moment instances for dates', () => {
36+
let Config = new config(),
37+
dates = ['from', 'to'];
38+
39+
dates.forEach(date => {
40+
Config.set(date, "2017-08-01");
41+
expect(typeof Config.get(date).format).to.equal("function");
42+
});
43+
});
44+
45+
it('makes durations human readable', () => {
46+
let Config = new config,
47+
humanReadable = "1d 4h 30m 10s",
48+
seconds = 45010;
49+
50+
expect(Config.toHumanReadable(seconds)).to.equal(humanReadable);
51+
});
52+
});

src/include/cli.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ class cli {
4848

4949
static get party() {
5050
return '🥑';
51-
// return '🍺';
5251
}
5352

5453
/**

0 commit comments

Comments
 (0)