forked from sumitchawla/timezone-names
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
92 lines (70 loc) · 2.82 KB
/
test.js
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
var tz = require("./index.js");
var assert = require("assert");
describe("Tests", function() {
it('Test Pacific Standard Time', function(done){
var timezone = tz.getTimezoneByName('Pacific Standard Time');
console.log(timezone);
assert(timezone);
assert.equal(timezone.Name, 'Pacific Standard Time');
assert.equal(timezone.Abbreviation, 'PST');
assert.equal(timezone.Offset, '-8 hours');
var offset = tz.getTimezoneOffsetByName('Pacific Standard Time');
console.log(offset);
assert(offset);
assert.equal(offset.Hours, -8);
assert.equal(offset.Minutes,0);
assert.equal(offset.TotalMinutesOffset,-480);
done();
})
it('Test Australian Central Standard Time', function(done){
var timezone = tz.getTimezoneByName('Australian Central Standard Time');
assert(timezone);
assert.equal(timezone.Name, 'Australian Central Standard Time');
assert.equal(timezone.Abbreviation, 'ACST');
assert.equal(timezone.Offset, '9:30 hours');
var offset = tz.getTimezoneOffsetByName('Australian Central Standard Time');
assert(offset);
assert.equal(offset.Hours, 9);
assert.equal(offset.Minutes,30);
assert.equal(offset.TotalMinutesOffset,570);
done();
})
it('Test Venezuelan Standard Time', function(done){
var timezone = tz.getTimezoneByName('Venezuelan Standard Time');
assert(timezone);
assert.equal(timezone.Name, 'Venezuelan Standard Time');
assert.equal(timezone.Abbreviation, 'VET');
assert.equal(timezone.Offset, '-4:30 hours');
var offset = tz.getTimezoneOffsetByName('Venezuelan Standard Time');
assert(offset);
assert.equal(offset.Hours, -4);
assert.equal(offset.Minutes,30);
assert.equal(offset.TotalMinutesOffset,-270);
done();
})
it('Test India Standard Time', function(done){
var timezone = tz.getTimezoneByName('India Standard Time');
assert(timezone);
assert.equal(timezone.Name, 'India Standard Time');
assert.equal(timezone.Abbreviation, 'IST');
assert.equal(timezone.Offset, '5:30 hours');
var offset = tz.getTimezoneOffsetByName('India Standard Time');
assert(offset);
assert.equal(offset.Hours, 5);
assert.equal(offset.Minutes,30);
assert.equal(offset.TotalMinutesOffset,330);
done();
})
it('Data Sanity check', function(done){
var timezones = tz.getAll();
for (var i = 0; i < timezones.length; i++) {
var t = timezones[i];
var timezone = tz.getTimezoneByName(t.Name);
assert(timezone);
var offset = tz.getTimezoneOffsetByName(t.Name);
assert(offset);
console.log(timezone, offset);
}
done();
})
});