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
|
// @flow
/* eslint-env mocha */
import assert from 'power-assert'
import nextFriday from '.'
describe('nextFriday', () => {
it('returns the following Friday given various dates before the same', () => {
assert.deepStrictEqual(
nextFriday(new Date(2020, 2 /* Mar */, 23)),
new Date(2020, 2 /* Mar */, 27)
)
assert.deepStrictEqual(
nextFriday(new Date(2020, 2 /* Mar */, 22)),
new Date(2020, 2 /* Mar */, 27)
)
assert.deepStrictEqual(
nextFriday(new Date(2020, 2 /* Mar */, 21)),
new Date(2020, 2 /* Mar */, 27)
)
assert.deepStrictEqual(
nextFriday(new Date(2020, 2 /* Mar */, 20)),
new Date(2020, 2 /* Mar */, 27)
)
assert.deepStrictEqual(
nextFriday(new Date(2020, 2 /* Mar */, 19)),
new Date(2020, 2 /* Mar */, 20)
)
assert.deepStrictEqual(
nextFriday(new Date(2020, 2 /* Mar */, 18)),
new Date(2020, 2 /* Mar */, 20)
)
assert.deepStrictEqual(
nextFriday(new Date(2020, 2 /* Mar */, 17)),
new Date(2020, 2 /* Mar */, 20)
)
})
it('returns `Invalid Date` if the given date is invalid', () => {
assert(nextFriday(new Date(NaN)) instanceof Date)
})
})
|