-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.js
39 lines (33 loc) · 804 Bytes
/
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
32
33
34
35
36
37
38
39
var loop = require('./')
var test = require('tape').test
test("loops expected number of times", function(t) {
var count = 0
t.plan(3)
var engine = loop(function(dt) {
t.equal(typeof dt, 'number', 'iteration')
count++
if (count>=3)
engine.stop()
}).start()
})
test("can attach tick events", function(t) {
var count = 0,
tested = false
t.plan(6)
var engine = loop().start()
engine.on('tick', tick)
function tick(dt) {
t.equal(typeof dt, 'number', 'iteration')
count++
if (count>=3) {
engine.stop()
engine.emit('test')
}
}
engine.on('test', function() {
if (tested) return
tested = true
count = 0
engine.start()
})
})