1 | var test = require('tape')
|
2 | , raf = require('./index')
|
3 |
|
4 | test('continues to emit events', function(t) {
|
5 | var canvas = typeof document === "undefined" ? {} : document.createElement('canvas')
|
6 | , ee = raf(canvas)
|
7 | , times = 0
|
8 |
|
9 | t.plan(10)
|
10 |
|
11 | canvas.width = canvas.height = 100
|
12 |
|
13 | ee
|
14 | .on('data', function(dt) {
|
15 | t.ok(dt >= 0, "time has passed")
|
16 | if(++times == 10) {
|
17 | ee.pause()
|
18 | t.end()
|
19 | }
|
20 | })
|
21 | })
|
22 |
|
23 | test('default tick function gets data', function(t) {
|
24 | var canvas = typeof document === "undefined" ? {} : document.createElement('canvas')
|
25 | , ee = raf(canvas, function tick(dt) {
|
26 | t.true(!!dt, 'got data')
|
27 | ee.pause()
|
28 | t.end()
|
29 | })
|
30 | })
|
31 |
|