-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.js
28 lines (22 loc) · 934 Bytes
/
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
import test from 'ava';
import fn from '.';
test('Get Id By Offset', t => {
t.is(fn.getIdByOffset('-10:00'), 2);
t.is(fn.getIdByOffset('-04:00'), 13);
t.is(fn.getIdByOffset(-10), 2);
t.is(fn.getIdByOffset(-4), 13);
t.is(fn.getIdByOffset('11:00'), 60);
t.is(fn.getIdByOffset(11), 60);
let error = t.throws(() => fn.getIdByOffset([]));
t.is(error.message, 'Not a valid offset input, received object');
let error2 = t.throws(() => fn.getIdByOffset(-14));
t.is(error2.message, 'Not a valid offset, offset should be between -12 to 12');
let error3 = t.throws(() => fn.getIdByOffset(14));
t.is(error3.message, 'Not a valid offset, offset should be between -12 to 12');
let error4 = t.throws(() => fn.getIdByOffset('-4:00'));
t.is(error4.message, 'Not a valid offset');
});
test('Get Name By Id', t => {
t.is(fn.getTimezone(1), 'GMT-11:00, Samoa (Samoa)');
t.is(fn.getTimezone(4), 'GMT-08:00, Pacific (San Jose)');
});