forked from angular/angular.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstyleSpec.js
76 lines (52 loc) · 2.25 KB
/
styleSpec.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
'use strict';
describe('style', function() {
var element;
afterEach(function() {
dealoc(element);
});
it('should compile style element without binding', inject(function($compile, $rootScope) {
element = jqLite('<style type="text/css">.header{font-size:1.5em; h3{font-size:1.5em}}</style>');
$compile(element)($rootScope);
$rootScope.$digest();
expect(element[0].innerHTML).toBe('.header{font-size:1.5em; h3{font-size:1.5em}}');
}));
it('should compile style element with one simple bind', inject(function($compile, $rootScope) {
element = jqLite('<style type="text/css">.some-container{ width: {{elementWidth}}px; }</style>');
$compile(element)($rootScope);
$rootScope.$digest();
expect(element[0].innerHTML).toBe('.some-container{ width: px; }');
$rootScope.$apply(function() {
$rootScope.elementWidth = 200;
});
expect(element[0].innerHTML).toBe('.some-container{ width: 200px; }');
}));
it('should compile style element with one bind', inject(function($compile, $rootScope) {
element = jqLite('<style type="text/css">.header{ h3 { font-size: {{fontSize}}em }}</style>');
$compile(element)($rootScope);
$rootScope.$digest();
expect(element[0].innerHTML).toBe('.header{ h3 { font-size: em }}');
$rootScope.$apply(function() {
$rootScope.fontSize = 1.5;
});
expect(element[0].innerHTML).toBe('.header{ h3 { font-size: 1.5em }}');
}));
it('should compile style element with two binds', inject(function($compile, $rootScope) {
element = jqLite('<style type="text/css">.header{ h3 { font-size: {{fontSize}}{{unit}} }}</style>');
$compile(element)($rootScope);
$rootScope.$digest();
expect(element[0].innerHTML).toBe('.header{ h3 { font-size: }}');
$rootScope.$apply(function() {
$rootScope.fontSize = 1.5;
$rootScope.unit = 'em';
});
expect(element[0].innerHTML).toBe('.header{ h3 { font-size: 1.5em }}');
}));
it('should compile content of element with style attr', inject(function($compile, $rootScope) {
element = jqLite('<div style="some">{{bind}}</div>');
$compile(element)($rootScope);
$rootScope.$apply(function() {
$rootScope.bind = 'value';
});
expect(element.text()).toBe('value');
}));
});