@@ -9,13 +9,65 @@ describe('style', function() {
9
9
} ) ;
10
10
11
11
12
- it ( 'should not compile style element' , inject ( function ( $compile , $rootScope ) {
13
- element = jqLite ( '<style type="text/css">should {{notBound }}</style>' ) ;
12
+ it ( 'should compile style element without binding ' , inject ( function ( $compile , $rootScope ) {
13
+ element = jqLite ( '<style type="text/css">.header{font-size:1.5em; h3{font-size:1.5em }}</style>' ) ;
14
14
$compile ( element ) ( $rootScope ) ;
15
15
$rootScope . $digest ( ) ;
16
16
17
17
// read innerHTML and trim to pass on IE8
18
- expect ( trim ( element [ 0 ] . innerHTML ) ) . toBe ( 'should {{notBound}}' ) ;
18
+ expect ( trim ( element [ 0 ] . innerHTML ) ) . toBe ( '.header{font-size:1.5em; h3{font-size:1.5em}}' ) ;
19
+ } ) ) ;
20
+
21
+
22
+ it ( 'should compile style element with one simple bind' , inject ( function ( $compile , $rootScope ) {
23
+ element = jqLite ( '<style type="text/css">.some-container{ width: {{elementWidth}}px; }</style>' ) ;
24
+ $compile ( element ) ( $rootScope ) ;
25
+ $rootScope . $digest ( ) ;
26
+
27
+ // read innerHTML and trim to pass on IE8
28
+ expect ( trim ( element [ 0 ] . innerHTML ) ) . toBe ( '.some-container{ width: px; }' ) ;
29
+
30
+ $rootScope . $apply ( function ( ) {
31
+ $rootScope . elementWidth = 200 ;
32
+ } ) ;
33
+
34
+ // read innerHTML and trim to pass on IE8
35
+ expect ( trim ( element [ 0 ] . innerHTML ) ) . toBe ( '.some-container{ width: 200px; }' ) ;
36
+ } ) ) ;
37
+
38
+
39
+ it ( 'should compile style element with one bind' , inject ( function ( $compile , $rootScope ) {
40
+ element = jqLite ( '<style type="text/css">.header{ h3 { font-size: {{fontSize}}em }}</style>' ) ;
41
+ $compile ( element ) ( $rootScope ) ;
42
+ $rootScope . $digest ( ) ;
43
+
44
+ // read innerHTML and trim to pass on IE8
45
+ expect ( trim ( element [ 0 ] . innerHTML ) ) . toBe ( '.header{ h3 { font-size: em }}' ) ;
46
+
47
+ $rootScope . $apply ( function ( ) {
48
+ $rootScope . fontSize = 1.5 ;
49
+ } ) ;
50
+
51
+ // read innerHTML and trim to pass on IE8
52
+ expect ( trim ( element [ 0 ] . innerHTML ) ) . toBe ( '.header{ h3 { font-size: 1.5em }}' ) ;
53
+ } ) ) ;
54
+
55
+
56
+ it ( 'should compile style element with two binds' , inject ( function ( $compile , $rootScope ) {
57
+ element = jqLite ( '<style type="text/css">.header{ h3 { font-size: {{fontSize}}{{unit}} }}</style>' ) ;
58
+ $compile ( element ) ( $rootScope ) ;
59
+ $rootScope . $digest ( ) ;
60
+
61
+ // read innerHTML and trim to pass on IE8
62
+ expect ( trim ( element [ 0 ] . innerHTML ) ) . toBe ( '.header{ h3 { font-size: }}' ) ;
63
+
64
+ $rootScope . $apply ( function ( ) {
65
+ $rootScope . fontSize = 1.5 ;
66
+ $rootScope . unit = 'em' ;
67
+ } ) ;
68
+
69
+ // read innerHTML and trim to pass on IE8
70
+ expect ( trim ( element [ 0 ] . innerHTML ) ) . toBe ( '.header{ h3 { font-size: 1.5em }}' ) ;
19
71
} ) ) ;
20
72
21
73
0 commit comments