forked from vvo/in-viewport
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdispose.js
More file actions
47 lines (41 loc) · 1.05 KB
/
dispose.js
File metadata and controls
47 lines (41 loc) · 1.05 KB
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
40
41
42
43
44
45
46
47
describe('using the watcher API to dispose and watch again', function() {
require('./fixtures/bootstrap.js');
beforeEach(h.clean);
afterEach(h.clean);
var element;
var watcher;
var visible = false;
beforeEach(function(done) {
element = h.createTest({
style: {
top: '10000px'
}
});
h.insertTest(element);
watcher = inViewport(element, function() {
visible = true;
});
// let in-viewport add the node to his watches
setTimeout(done, 20);
});
describe('when the watcher is not active', function() {
beforeEach(function() {
watcher.dispose();
});
beforeEach(h.scroller(0, 10000));
beforeEach(h.scroller(0, 0));
it('cb not called', function() {
assert.strictEqual(visible, false);
});
});
describe('when the watcher is active', function() {
beforeEach(function() {
watcher.watch();
});
beforeEach(h.scroller(0, 10000));
beforeEach(h.scroller(0, 0));
it('cb called', function() {
assert.strictEqual(visible, true);
});
});
});