-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathnodeParseTime.js
More file actions
26 lines (22 loc) · 860 Bytes
/
Copy pathnodeParseTime.js
File metadata and controls
26 lines (22 loc) · 860 Bytes
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
var pt = require('./dist/parseTime.js'),
colors = require('colors'),
tests = [],
fail = false;
process.env.TZ = 'Europe/Berlin';
tests = [
{'name': 'yesterday', 'input': 'yesterday', 'mode':'relative', 'output': -86400000},
{'name': 'birthday', 'input': '06.06.1989', 'mode':'absolute', 'output': 613134000000},
{'name': '4thofjuly', 'input': 'am 4 Juli 2014', 'mode':'absolute', 'output': 1404424800000},
{'name': 'tomorrow', 'input': 'tomorrow', 'mode':'relative', 'output': 86400000}
];
for(var i in tests) {
if(pt(tests[i].input)[tests[i].mode] === tests[i].output) {
console.log(tests[i].name.green);
} else {
console.log(tests[i].name.red + " should be: " + tests[i].output + " but is: " + pt(tests[i].input)[tests[i].mode]);
fail = true;
}
}
if(fail === true) {
process.exit(1);
}