mirror of https://github.com/lukechilds/docs.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
583 B
28 lines
583 B
var test = require("tape")
|
|
var setTimeout = require("timers").setTimeout
|
|
|
|
var now = require("../index")
|
|
var seeded = require("../seed")
|
|
|
|
test("date", function (assert) {
|
|
var ts = now()
|
|
var ts2 = Date.now()
|
|
assert.equal(ts, ts2)
|
|
assert.end()
|
|
})
|
|
|
|
test("seeded", function (assert) {
|
|
var time = seeded(40)
|
|
var ts = time()
|
|
|
|
within(assert, time(), 40, 5)
|
|
setTimeout(function () {
|
|
within(assert, time(), 90, 10)
|
|
assert.end()
|
|
}, 50)
|
|
})
|
|
|
|
function within(assert, a, b, offset) {
|
|
assert.ok(a + offset > b)
|
|
assert.ok(a - offset < b)
|
|
}
|
|
|