summaryrefslogtreecommitdiff
path: root/date-fns/src/nextTuesday/test.ts
blob: ddc9c9c9cd1db6aec8917ff8e88808d9d05d72a3 (plain)
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
// @flow
/* eslint-env mocha */

import assert from 'power-assert'
import nextTuesday from '.'

describe('nextTuesday', function () {
  it('returns the following Tuesday given various dates before the same', function () {
    assert.deepStrictEqual(
      nextTuesday(new Date(2020, 2 /* Mar */, 23)),
      new Date(2020, 2 /* Mar */, 24)
    )

    assert.deepStrictEqual(
      nextTuesday(new Date(2020, 2 /* Mar */, 22)),
      new Date(2020, 2 /* Mar */, 24)
    )

    assert.deepStrictEqual(
      nextTuesday(new Date(2020, 3 /* Apr */, 11)),
      new Date(2020, 3 /* Apr */, 14)
    )

    assert.deepStrictEqual(
      nextTuesday(new Date(2020, 2 /* Mar */, 20)),
      new Date(2020, 2 /* Mar */, 24)
    )

    assert.deepStrictEqual(
      nextTuesday(new Date(2020, 2 /* Mar */, 19)),
      new Date(2020, 2 /* Mar */, 24)
    )

    assert.deepStrictEqual(
      nextTuesday(new Date(2020, 2 /* Mar */, 18)),
      new Date(2020, 2 /* Mar */, 24)
    )

    assert.deepStrictEqual(
      nextTuesday(new Date(2020, 2 /* Mar */, 17)),
      new Date(2020, 2 /* Mar */, 24)
    )
  })
  it('returns `Invalid Date` if the given date is invalid', function () {
    assert(nextTuesday(new Date(NaN)) instanceof Date)
  })
})