-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
31 lines (23 loc) · 1.42 KB
/
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
// --------------------------------------------------------------------------------------------------------------------
// tyn.io - (c) 2015 Tynio.
// --------------------------------------------------------------------------------------------------------------------
// npm
var test = require('tape')
// local
var dateSlice = require('./')
// --------------------------------------------------------------------------------------------------------------------
test(function(t) {
var dates = [
{ date : new Date('2015-01-01T23:44:22.123Z'), interval : 1000, slice : new Date('2015-01-01T23:44:22.000Z')},
{ date : new Date('2015-01-01T23:44:22.123Z'), interval : 15 * 1000, slice : new Date('2015-01-01T23:44:15.000Z')},
{ date : new Date('2015-01-01T23:44:22.123Z'), interval : 60 * 1000, slice : new Date('2015-01-01T23:44:00.000Z')},
{ date : new Date('2015-01-01T23:00:00.000Z'), interval : 60 * 60 * 1000, slice : new Date('2015-01-01T23:00:00.000Z')},
{ date : new Date('2015-01-01T23:44:22.123Z'), interval : 24 * 60 * 60 * 1000, slice : new Date('2015-01-01T00:00:00.000Z')},
]
t.plan(dates.length)
dates.forEach(function(date, i) {
t.deepEqual(dateSlice.from(date.date, date.interval), date.slice, 'Test ' + i + ' is okay')
})
t.end()
})
// --------------------------------------------------------------------------------------------------------------------