Skip to content

Commit

Permalink
Update tests to make it work on Travis which have a different timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
bredele committed Apr 6, 2018
1 parent aa84199 commit abdef44
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions test/runout.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,61 +8,65 @@ const runout = require('..')

test('should filter valid and expired dates from a given expiration limit', assert => {
assert.plan(1)
const obj = runout([
const dates = [
new Date('01-01-2000').getTime(),
new Date('01-01-2100').getTime(),
new Date('01-01-2300').getTime(),
], new Date('01-01-2101').getTime())
]
const obj = runout(dates, new Date('01-01-2101').getTime())
assert.deepEqual(obj, {
valid: [946710000000, 4102470000000],
expired: [10413817200000],
valid: [dates[0], dates[1]],
expired: [dates[2]],
soon: []
})
})


test('should convert dates in ms', assert => {
assert.plan(1)
const obj = runout([
const dates = [
new Date('01-01-2000'),
new Date('01-01-2100'),
new Date('01-01-2300'),
], new Date('01-01-2101'))
]
const obj = runout(dates, new Date('01-01-2101'))
assert.deepEqual(obj, {
valid: [946710000000, 4102470000000],
expired: [10413817200000],
valid: [dates[0].getTime(), dates[1].getTime()],
expired: [dates[2].getTime()],
soon: []
})
})


test('should convert date strings into ms and sort them', assert => {
assert.plan(1)
const obj = runout([
const dates = [
new Date('01-01-2000'),
'01-01-2100',
new Date('01-01-2300'),
], '01-01-2101')
]
const obj = runout(dates, '01-01-2101')
assert.deepEqual(obj, {
valid: [946710000000, 4102470000000],
expired: [10413817200000],
valid: [dates[0].getTime(), new Date(dates[1]).getTime()],
expired: [dates[2].getTime()],
soon: []
})
})


test('should filter dates that expire soon', assert => {
assert.plan(1)
const obj = runout([
const dates = [
new Date('01-01-2000'),
new Date('01-01-2100'),
new Date('12-06-2100'),
new Date('01-01-2300'),
], new Date('01-01-2101'), oneyear())
]
const obj = runout(dates, new Date('01-01-2101'), oneyear())
assert.deepEqual(obj, {
valid: [946710000000],
expired: [10413817200000],
soon: [4102470000000, 4131759600000]
valid: [dates[0].getTime()],
expired: [dates[3].getTime()],
soon: [dates[1].getTime(), dates[2].getTime()]
})
})

Expand Down

0 comments on commit abdef44

Please sign in to comment.