forked from vvo/in-viewport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
detached.js
48 lines (38 loc) · 1.03 KB
/
detached.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
40
41
42
43
44
45
46
47
48
describe('detached DOM node', function() {
require('./fixtures/bootstrap.js');
beforeEach(h.clean);
afterEach(h.clean);
var visible = false;
var test;
beforeEach(function() {
test = h.createTest();
inViewport(test, function() {
visible = true;
});
});
it('cb not called', function() {
assert.strictEqual(visible, false);
});
describe('when inserted into the DOM', function() {
beforeEach(function() {
h.insertTest(test);
});
describe('without scrolling', function () {
if (typeof MutationObserver === 'function') {
describe('when the browser supports `MutationObserver`', function () {
beforeEach(h.wait(50));
it('cb called', function() {
assert.strictEqual(visible, true);
});
});
}
});
describe('with scrolling', function () {
beforeEach(h.scroller(0, 100));
beforeEach(h.scroller(0, 0));
it('cb called', function() {
assert.strictEqual(visible, true);
});
});
});
});