1
- describe ( 'progressbar directive' , function ( ) {
2
- describe ( '$progressSuppressWarning' , function ( ) {
3
- beforeEach ( module ( 'ui.bootstrap.progressbar' ) ) ;
4
- beforeEach ( module ( 'template/progressbar/progress.html' , 'template/progressbar/bar.html' ) ) ;
5
-
6
- it ( 'should suppress warning' , function ( ) {
7
- module ( function ( $provide ) {
8
- $provide . value ( '$progressSuppressWarning' , true ) ;
9
- } ) ;
10
-
11
- inject ( function ( $compile , $log , $rootScope ) {
12
- spyOn ( $log , 'warn' ) ;
13
-
14
- $rootScope . objects = [
15
- { value : 10 , type : 'success' } ,
16
- { value : 50 , type : 'warning' } ,
17
- { value : 20 }
18
- ] ;
19
- var element = $compile ( '<progress animate="false"><bar ng-repeat="o in objects" value="o.value" type="{{o.type}}">{{o.value}}</bar></progress>' ) ( $rootScope ) ;
20
- $rootScope . $digest ( ) ;
21
-
22
- expect ( $log . warn . calls . count ( ) ) . toBe ( 0 ) ;
23
- } ) ;
24
- } ) ;
25
-
26
- it ( 'should give warning by default' , inject ( function ( $compile , $log , $rootScope ) {
27
- spyOn ( $log , 'warn' ) ;
28
-
29
- $rootScope . objects = [
30
- { value : 10 , type : 'success' } ,
31
- { value : 50 , type : 'warning' } ,
32
- { value : 20 }
33
- ] ;
34
- var element = $compile ( '<progress animate="false"><bar ng-repeat="o in objects" value="o.value" type="{{o.type}}">{{o.value}}</bar></progress>' ) ( $rootScope ) ;
35
- $rootScope . $digest ( ) ;
36
-
37
- expect ( $log . warn . calls . count ( ) ) . toBe ( 4 ) ;
38
- expect ( $log . warn . calls . argsFor ( 0 ) ) . toEqual ( [ 'progress is now deprecated. Use uib-progress instead' ] ) ;
39
- expect ( $log . warn . calls . argsFor ( 1 ) ) . toEqual ( [ 'bar is now deprecated. Use uib-bar instead' ] ) ;
40
- expect ( $log . warn . calls . argsFor ( 2 ) ) . toEqual ( [ 'bar is now deprecated. Use uib-bar instead' ] ) ;
41
- expect ( $log . warn . calls . argsFor ( 3 ) ) . toEqual ( [ 'bar is now deprecated. Use uib-bar instead' ] ) ;
42
- } ) ) ;
43
- } ) ;
44
- } ) ;
45
-
46
1
describe ( 'progressbar directive' , function ( ) {
47
2
var $rootScope , $compile , element ;
48
3
beforeEach ( module ( 'ui.bootstrap.progressbar' ) ) ;
@@ -51,7 +6,7 @@ describe('progressbar directive', function() {
51
6
$compile = _$compile_ ;
52
7
$rootScope = _$rootScope_ ;
53
8
$rootScope . value = 22 ;
54
- element = $compile ( '<progressbar animate="false" value="value" title="foo">{{value}} %</progressbar>' ) ( $rootScope ) ;
9
+ element = $compile ( '<uib- progressbar animate="false" value="value" title="foo">{{value}} %</uib- progressbar>' ) ( $rootScope ) ;
55
10
$rootScope . $digest ( ) ;
56
11
} ) ) ;
57
12
@@ -85,7 +40,7 @@ describe('progressbar directive', function() {
85
40
} ) ;
86
41
87
42
it ( 'has the default aria-labelledby value of `progressbar`' , function ( ) {
88
- element = $compile ( '<progressbar animate="false" value="value">{{value}} %</progressbar>' ) ( $rootScope ) ;
43
+ element = $compile ( '<uib- progressbar animate="false" value="value">{{value}} %</uib- progressbar>' ) ( $rootScope ) ;
89
44
$rootScope . $digest ( ) ;
90
45
var bar = getBar ( 0 ) ;
91
46
expect ( bar . attr ( 'aria-labelledby' ) ) . toBe ( 'progressbar' ) ;
@@ -140,7 +95,7 @@ describe('progressbar directive', function() {
140
95
describe ( '"max" attribute' , function ( ) {
141
96
beforeEach ( inject ( function ( ) {
142
97
$rootScope . max = 200 ;
143
- element = $compile ( '<progressbar max="max" animate="false" value="value">{{value}}/{{max}}</progressbar>' ) ( $rootScope ) ;
98
+ element = $compile ( '<uib- progressbar max="max" animate="false" value="value">{{value}}/{{max}}</uib- progressbar>' ) ( $rootScope ) ;
144
99
$rootScope . $digest ( ) ;
145
100
} ) ) ;
146
101
@@ -181,7 +136,7 @@ describe('progressbar directive', function() {
181
136
describe ( '"type" attribute' , function ( ) {
182
137
beforeEach ( inject ( function ( ) {
183
138
$rootScope . type = 'success' ;
184
- element = $compile ( '<progressbar value="value" type="{{type}}"></progressbar>' ) ( $rootScope ) ;
139
+ element = $compile ( '<uib- progressbar value="value" type="{{type}}"></uib- progressbar>' ) ( $rootScope ) ;
185
140
$rootScope . $digest ( ) ;
186
141
} ) ) ;
187
142
@@ -363,3 +318,79 @@ describe('progressbar directive', function() {
363
318
} ) ;
364
319
} ) ;
365
320
} ) ;
321
+
322
+ /* Deprecation tests below */
323
+
324
+ describe ( 'progressbar deprecation' , function ( ) {
325
+ beforeEach ( module ( 'ui.bootstrap.progressbar' ) ) ;
326
+ beforeEach ( module ( 'template/progressbar/progress.html' , 'template/progressbar/bar.html' , 'template/progressbar/progressbar.html' ) ) ;
327
+
328
+ describe ( 'progress & bar directives' , function ( ) {
329
+ it ( 'should suppress warning' , function ( ) {
330
+ module ( function ( $provide ) {
331
+ $provide . value ( '$progressSuppressWarning' , true ) ;
332
+ } ) ;
333
+
334
+ inject ( function ( $compile , $log , $rootScope ) {
335
+ spyOn ( $log , 'warn' ) ;
336
+
337
+ $rootScope . objects = [
338
+ { value : 10 , type : 'success' } ,
339
+ { value : 50 , type : 'warning' } ,
340
+ { value : 20 }
341
+ ] ;
342
+ var element = $compile ( '<progress animate="false"><bar ng-repeat="o in objects" value="o.value" type="{{o.type}}">{{o.value}}</bar></progress>' ) ( $rootScope ) ;
343
+ $rootScope . $digest ( ) ;
344
+
345
+ expect ( $log . warn . calls . count ( ) ) . toBe ( 0 ) ;
346
+ } ) ;
347
+ } ) ;
348
+
349
+ it ( 'should give warning by default' , inject ( function ( $compile , $log , $rootScope ) {
350
+ spyOn ( $log , 'warn' ) ;
351
+
352
+ $rootScope . objects = [
353
+ { value : 10 , type : 'success' } ,
354
+ { value : 50 , type : 'warning' } ,
355
+ { value : 20 }
356
+ ] ;
357
+ var element = $compile ( '<progress animate="false"><bar ng-repeat="o in objects" value="o.value" type="{{o.type}}">{{o.value}}</bar></progress>' ) ( $rootScope ) ;
358
+ $rootScope . $digest ( ) ;
359
+
360
+ expect ( $log . warn . calls . count ( ) ) . toBe ( 4 ) ;
361
+ expect ( $log . warn . calls . argsFor ( 0 ) ) . toEqual ( [ 'progress is now deprecated. Use uib-progress instead.' ] ) ;
362
+ expect ( $log . warn . calls . argsFor ( 1 ) ) . toEqual ( [ 'bar is now deprecated. Use uib-bar instead.' ] ) ;
363
+ expect ( $log . warn . calls . argsFor ( 2 ) ) . toEqual ( [ 'bar is now deprecated. Use uib-bar instead.' ] ) ;
364
+ expect ( $log . warn . calls . argsFor ( 3 ) ) . toEqual ( [ 'bar is now deprecated. Use uib-bar instead.' ] ) ;
365
+ } ) ) ;
366
+ } ) ;
367
+
368
+ describe ( 'progressbar directive' , function ( ) {
369
+ it ( 'should suppress warning' , function ( ) {
370
+ module ( function ( $provide ) {
371
+ $provide . value ( '$progressSuppressWarning' , true ) ;
372
+ } ) ;
373
+
374
+ inject ( function ( $compile , $log , $rootScope ) {
375
+ spyOn ( $log , 'warn' ) ;
376
+
377
+ $rootScope . value = 22 ;
378
+ var element = $compile ( '<progressbar animate="false" value="value" title="foo">{{value}} %</progressbar>' ) ( $rootScope ) ;
379
+ $rootScope . $digest ( ) ;
380
+
381
+ expect ( $log . warn . calls . count ( ) ) . toBe ( 0 ) ;
382
+ } ) ;
383
+ } ) ;
384
+
385
+ it ( 'should give warning by default' , inject ( function ( $compile , $log , $rootScope ) {
386
+ spyOn ( $log , 'warn' ) ;
387
+
388
+ $rootScope . value = 22 ;
389
+ var element = $compile ( '<progressbar animate="false" value="value" title="foo">{{value}} %</progressbar>' ) ( $rootScope ) ;
390
+ $rootScope . $digest ( ) ;
391
+
392
+ expect ( $log . warn . calls . count ( ) ) . toBe ( 1 ) ;
393
+ expect ( $log . warn . calls . argsFor ( 0 ) ) . toEqual ( [ 'progressbar is now deprecated. Use uib-progressbar instead.' ] ) ;
394
+ } ) ) ;
395
+ } ) ;
396
+ } ) ;
0 commit comments