This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/date-now/test/index.js

29 lines
583 B
JavaScript
Raw Normal View History

2019-08-11 18:48:02 +00:00
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)
}