-
Notifications
You must be signed in to change notification settings - Fork 19
/
expiration-test.js
42 lines (33 loc) · 899 Bytes
/
expiration-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
'use strict'
const test = require('tape')
const expiration = require('./expiration')
test('expiration', function (t) {
t.ok(expiration.isPast(
new Date().getMonth(),
new Date().getFullYear()
))
t.notOk(expiration.isPast(
new Date().getMonth() + 1,
new Date().getFullYear()
))
t.test('month', function (t) {
const month = expiration.month
t.equal(month.parse('12'), 12)
t.end()
})
t.test('year', function (t) {
const year = expiration.year
t.equal(year.format('2012'), '2012')
t.equal(year.format(2012), '2012')
t.equal(year.format(2014, true), '14')
t.equal(year.format(2000, true), '00')
t.ok(year.isValid(2015))
t.notOk(year.isValid('2015'))
t.notOk(year.isValid(2015.5))
t.notOk(year.isPast(new Date().getFullYear()))
t.notOk(year.isPast(), 2100)
t.ok(year.isPast(2000))
t.end()
})
t.end()
})