fix tests point in time 💚

This commit is contained in:
Jannis R 2017-12-11 16:33:17 +01:00
parent 3c9c8433dc
commit 130ffeccf9
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
2 changed files with 7 additions and 8 deletions

View file

@ -40,8 +40,8 @@
"devDependencies": {
"co": "^4.6.0",
"db-stations": "^1.25.0",
"floordate": "^3.0.0",
"is-roughly-equal": "^0.1.0",
"luxon": "^0.2.7",
"tap-spec": "^4.1.1",
"tape": "^4.8.0",
"tape-promise": "^2.0.1",

View file

@ -1,7 +1,7 @@
'use strict'
const isRoughlyEqual = require('is-roughly-equal')
const floor = require('floordate')
const {DateTime} = require('luxon')
const assertValidStation = (t, s, coordsOptional = false) => {
t.equal(typeof s.type, 'string')
@ -80,13 +80,12 @@ const assertValidStopover = (t, s, coordsOptional = false) => {
assertValidStation(t, s.station, coordsOptional)
}
const minute = 60 * 1000
const hour = 60 * minute
const day = 24 * hour
const week = 7 * day
const hour = 60 * 60 * 1000
const week = 7 * 24 * hour
// next Monday
const when = new Date(+floor(new Date(), 'week') + week + 10 * hour)
// next Monday 10 am
const dt = DateTime.local().startOf('week').plus({weeks: 1, hours: 10})
const when = new Date(dt.toISO())
const isValidWhen = (w) => {
const ts = +new Date(w)
if (Number.isNaN(ts)) return false