-
Notifications
You must be signed in to change notification settings - Fork 98
/
Copy pathrobbery.spec.js
executable file
·76 lines (62 loc) · 2.59 KB
/
robbery.spec.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
/* eslint-env mocha */
'use strict';
const assert = require('assert');
const robbery = require('./robbery');
describe('robbery.getAppropriateMoment()', () => {
function getMomentFor(time) {
return robbery.getAppropriateMoment(
{
Danny: [
{ from: 'ПН 12:00+5', to: 'ПН 17:00+5' },
{ from: 'ВТ 13:00+5', to: 'ВТ 16:00+5' }
],
Rusty: [
{ from: 'ПН 11:30+5', to: 'ПН 16:30+5' },
{ from: 'ВТ 13:00+5', to: 'ВТ 16:00+5' }
],
Linus: [
{ from: 'ПН 09:00+3', to: 'ПН 14:00+3' },
{ from: 'ПН 21:00+3', to: 'ВТ 09:30+3' },
{ from: 'СР 09:30+3', to: 'СР 15:00+3' }
]
},
time,
{ from: '10:00+5', to: '18:00+5' }
);
}
it('должен форматировать существующий момент', () => {
const moment = getMomentFor(90);
assert.ok(moment.exists());
assert.strictEqual(
moment.format('Метим на %DD, старт в %HH:%MM!'),
'Метим на ВТ, старт в 11:30!'
);
});
it('должен вернуть пустую строку при форматировании несуществующего момента', () => {
const moment = getMomentFor(121);
assert.ok(!moment.exists());
assert.strictEqual(
moment.format('Метим на %DD, старт в %HH:%MM!'),
''
);
});
if (robbery.isStar) {
it('должен перемещаться на более поздний момент [*]', () => {
const moment = getMomentFor(90);
assert.ok(moment.tryLater());
assert.strictEqual(moment.format('%DD %HH:%MM'), 'ВТ 16:00');
assert.ok(moment.tryLater());
assert.strictEqual(moment.format('%DD %HH:%MM'), 'ВТ 16:30');
assert.ok(moment.tryLater());
assert.strictEqual(moment.format('%DD %HH:%MM'), 'СР 10:00');
});
it('не должен сдвигать момент, если более позднего нет [*]', () => {
const moment = getMomentFor(90);
assert.ok(moment.tryLater());
assert.ok(moment.tryLater());
assert.ok(moment.tryLater());
assert.ok(!moment.tryLater());
assert.strictEqual(moment.format('%DD %HH:%MM'), 'СР 10:00');
});
}
});