forked from angular/angular.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforceReflowSpec.js
52 lines (41 loc) · 1.37 KB
/
forceReflowSpec.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
49
50
51
52
'use strict';
describe('$$forceReflow', function() {
it('should issue a reflow by touching the `document.body.client` when no param is provided', function() {
module(function($provide) {
var doc = jqLite('<div></div>');
doc[0].body = {};
doc[0].body.offsetWidth = 10;
$provide.value('$document', doc);
});
inject(function($$forceReflow) {
var value = $$forceReflow();
expect(value).toBe(11);
});
});
it('should issue a reflow by touching the `domNode.offsetWidth` when a domNode param is provided',
inject(function($$forceReflow) {
var elm = {};
elm.offsetWidth = 100;
expect($$forceReflow(elm)).toBe(101);
}));
it('should issue a reflow by touching the `jqLiteNode[0].offsetWidth` when a jqLite node param is provided',
inject(function($$forceReflow) {
var elm = {};
elm.offsetWidth = 200;
elm = jqLite(elm);
expect($$forceReflow(elm)).toBe(201);
}));
describe('$animate with ngAnimateMock', function() {
beforeEach(module('ngAnimateMock'));
it('should keep track of how many reflows have been issued',
inject(function($$forceReflow, $animate) {
var elm = {};
elm.offsetWidth = 10;
expect($animate.reflows).toBe(0);
$$forceReflow(elm);
$$forceReflow(elm);
$$forceReflow(elm);
expect($animate.reflows).toBe(3);
}));
});
});