Sin descripción

index.js 583B

12345678910111213141516171819202122232425262728
  1. var test = require("tape")
  2. var setTimeout = require("timers").setTimeout
  3. var now = require("../index")
  4. var seeded = require("../seed")
  5. test("date", function (assert) {
  6. var ts = now()
  7. var ts2 = Date.now()
  8. assert.equal(ts, ts2)
  9. assert.end()
  10. })
  11. test("seeded", function (assert) {
  12. var time = seeded(40)
  13. var ts = time()
  14. within(assert, time(), 40, 5)
  15. setTimeout(function () {
  16. within(assert, time(), 90, 10)
  17. assert.end()
  18. }, 50)
  19. })
  20. function within(assert, a, b, offset) {
  21. assert.ok(a + offset > b)
  22. assert.ok(a - offset < b)
  23. }