3
3
describe ( 'ngClass' , function ( ) {
4
4
var element ;
5
5
6
+ beforeEach ( module ( function ( $compileProvider ) {
7
+ $compileProvider . debugInfoEnabled ( false ) ;
8
+ } ) ) ;
6
9
7
10
afterEach ( function ( ) {
8
11
dealoc ( element ) ;
@@ -39,9 +42,9 @@ describe('ngClass', function() {
39
42
} ) ) ;
40
43
41
44
42
- it ( 'should support adding multiple classes conditionally via a map of class names to boolean' +
45
+ it ( 'should support adding multiple classes conditionally via a map of class names to boolean ' +
43
46
'expressions' , inject ( function ( $rootScope , $compile ) {
44
- var element = $compile (
47
+ element = $compile (
45
48
'<div class="existing" ' +
46
49
'ng-class="{A: conditionA, B: conditionB(), AnotB: conditionA&&!conditionB()}">' +
47
50
'</div>' ) ( $rootScope ) ;
@@ -63,7 +66,7 @@ describe('ngClass', function() {
63
66
64
67
it ( 'should remove classes when the referenced object is the same but its property is changed' ,
65
68
inject ( function ( $rootScope , $compile ) {
66
- var element = $compile ( '<div ng-class="classes"></div>' ) ( $rootScope ) ;
69
+ element = $compile ( '<div ng-class="classes"></div>' ) ( $rootScope ) ;
67
70
$rootScope . classes = { A : true , B : true } ;
68
71
$rootScope . $digest ( ) ;
69
72
expect ( element . hasClass ( 'A' ) ) . toBeTruthy ( ) ;
@@ -124,15 +127,15 @@ describe('ngClass', function() {
124
127
$rootScope . $digest ( ) ;
125
128
$rootScope . dynCls = 'foo' ;
126
129
$rootScope . $digest ( ) ;
127
- expect ( element [ 0 ] . className ) . toBe ( 'ui-panel ui-selected ng-scope foo' ) ;
130
+ expect ( element [ 0 ] . className ) . toBe ( 'ui-panel ui-selected foo' ) ;
128
131
} ) ) ;
129
132
130
133
131
134
it ( 'should not add duplicate classes' , inject ( function ( $rootScope , $compile ) {
132
135
element = $compile ( '<div class="panel bar" ng-class="dynCls"></div>' ) ( $rootScope ) ;
133
136
$rootScope . dynCls = 'panel' ;
134
137
$rootScope . $digest ( ) ;
135
- expect ( element [ 0 ] . className ) . toBe ( 'panel bar ng-scope ' ) ;
138
+ expect ( element [ 0 ] . className ) . toBe ( 'panel bar' ) ;
136
139
} ) ) ;
137
140
138
141
@@ -142,7 +145,7 @@ describe('ngClass', function() {
142
145
$rootScope . $digest ( ) ;
143
146
$rootScope . dynCls = 'window' ;
144
147
$rootScope . $digest ( ) ;
145
- expect ( element [ 0 ] . className ) . toBe ( 'bar ng-scope window' ) ;
148
+ expect ( element [ 0 ] . className ) . toBe ( 'bar window' ) ;
146
149
} ) ) ;
147
150
148
151
@@ -153,15 +156,15 @@ describe('ngClass', function() {
153
156
element . addClass ( 'foo' ) ;
154
157
$rootScope . dynCls = '' ;
155
158
$rootScope . $digest ( ) ;
156
- expect ( element [ 0 ] . className ) . toBe ( 'ng-scope ' ) ;
159
+ expect ( element [ 0 ] . className ) . toBe ( '' ) ;
157
160
} ) ) ;
158
161
159
162
160
163
it ( 'should convert undefined and null values to an empty string' , inject ( function ( $rootScope , $compile ) {
161
164
element = $compile ( '<div ng-class="dynCls"></div>' ) ( $rootScope ) ;
162
165
$rootScope . dynCls = [ undefined , null ] ;
163
166
$rootScope . $digest ( ) ;
164
- expect ( element [ 0 ] . className ) . toBe ( 'ng-scope ' ) ;
167
+ expect ( element [ 0 ] . className ) . toBe ( '' ) ;
165
168
} ) ) ;
166
169
167
170
@@ -364,10 +367,14 @@ describe('ngClass', function() {
364
367
describe ( 'ngClass animations' , function ( ) {
365
368
var body , element , $rootElement ;
366
369
370
+ afterEach ( function ( ) {
371
+ dealoc ( element ) ;
372
+ } ) ;
373
+
367
374
it ( "should avoid calling addClass accidentally when removeClass is going on" , function ( ) {
368
375
module ( 'ngAnimateMock' ) ;
369
376
inject ( function ( $compile , $rootScope , $animate , $timeout ) {
370
- var element = angular . element ( '<div ng-class="val"></div>' ) ;
377
+ element = angular . element ( '<div ng-class="val"></div>' ) ;
371
378
var body = jqLite ( document . body ) ;
372
379
body . append ( element ) ;
373
380
$compile ( element ) ( $rootScope ) ;
@@ -432,7 +439,7 @@ describe('ngClass animations', function() {
432
439
digestQueue . shift ( ) ( ) ;
433
440
434
441
$rootScope . val = 'crazy' ;
435
- var element = angular . element ( '<div ng-class="val"></div>' ) ;
442
+ element = angular . element ( '<div ng-class="val"></div>' ) ;
436
443
jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
437
444
438
445
$compile ( element ) ( $rootScope ) ;
@@ -479,7 +486,7 @@ describe('ngClass animations', function() {
479
486
$rootScope . two = true ;
480
487
$rootScope . three = true ;
481
488
482
- var element = angular . element ( '<div ng-class="{one:one, two:two, three:three}"></div>' ) ;
489
+ element = angular . element ( '<div ng-class="{one:one, two:two, three:three}"></div>' ) ;
483
490
$compile ( element ) ( $rootScope ) ;
484
491
$rootScope . $digest ( ) ;
485
492
0 commit comments