1
- describe ( 'tabs' , function ( ) {
1
+ ddescribe ( 'tabs' , function ( ) {
2
2
3
3
describe ( 'miscellaneous' , function ( ) {
4
4
beforeEach ( module ( 'ionic' , function ( $provide ) {
@@ -387,10 +387,21 @@ describe('tabs', function() {
387
387
expect ( tabsCtrl . select ) . toHaveBeenCalledWith ( tabCtrl . $scope , true ) ;
388
388
} ) ;
389
389
390
- it ( 'should set iconOn and iconOff to icon if icon is given ' , function ( ) {
390
+ it ( 'should fallback to icon for icon-on and icon-off ' , function ( ) {
391
391
var el = setup ( 'icon=1' ) ;
392
- expect ( el . attr ( 'icon-on' ) ) . toBe ( '1' ) ;
393
- expect ( el . attr ( 'icon-off' ) ) . toBe ( '1' ) ;
392
+
393
+ expect ( el . isolateScope ( ) . getIconOn ( ) ) . toBe ( '1' ) ;
394
+ el . isolateScope ( ) . iconOn = 2 ;
395
+ expect ( el . isolateScope ( ) . getIconOn ( ) ) . toBe ( 2 ) ;
396
+ el . isolateScope ( ) . iconOn = null ;
397
+ expect ( el . isolateScope ( ) . getIconOn ( ) ) . toBe ( '1' ) ;
398
+
399
+ expect ( el . isolateScope ( ) . getIconOff ( ) ) . toBe ( '1' ) ;
400
+ el . isolateScope ( ) . iconOff = 3 ;
401
+ expect ( el . isolateScope ( ) . getIconOff ( ) ) . toBe ( 3 ) ;
402
+ el . isolateScope ( ) . iconOff = null ;
403
+ expect ( el . isolateScope ( ) . getIconOff ( ) ) . toBe ( '1' ) ;
404
+
394
405
} ) ;
395
406
396
407
it ( 'should select tab on click' , function ( ) {
@@ -408,20 +419,36 @@ describe('tabs', function() {
408
419
el . scope ( ) . $apply ( 'name = "joe"' ) ;
409
420
expect ( el . find ( '.tab-title' ) . html ( ) ) . toBe ( '<b>hi, joe!</b>' ) ;
410
421
} ) ;
422
+
423
+ it ( 'should change icon class with just icon' , function ( ) {
424
+ //In this case, icon-on and icon-off should be same
425
+ var el = setup ( 'icon={{icon}}' ) ;
426
+ el . scope ( ) . icon = "superIcon" ;
427
+ el . scope ( ) . $apply ( ) ;
428
+
429
+ el . isolateScope ( ) . isTabActive = function ( ) { return true ; } ;
430
+ el . isolateScope ( ) . $apply ( ) ;
431
+
432
+ expect ( el . find ( '.icon.superIcon' ) . length ) . toBe ( 1 ) ;
433
+ el . isolateScope ( ) . isTabActive = function ( ) { return false ; } ;
434
+ el . isolateScope ( ) . $apply ( ) ;
435
+
436
+ expect ( el . find ( '.icon.superIcon' ) . length ) . toBe ( 1 ) ;
437
+ } ) ;
411
438
it ( 'should change classes based on active' , function ( ) {
412
- var el = setup ( 'icon-on=on icon-off=off ' ) ;
439
+ var el = setup ( 'icon-on="{{true}}" icon-off="{{false}}" ' ) ;
413
440
414
441
el . isolateScope ( ) . isTabActive = function ( ) { return true ; } ;
415
442
el . isolateScope ( ) . $apply ( ) ;
416
443
expect ( el . hasClass ( 'active' ) ) . toBe ( true ) ;
417
- expect ( el . find ( '.icon.on ' ) . length ) . toBe ( 1 ) ;
418
- expect ( el . find ( '.icon.off ' ) . length ) . toBe ( 0 ) ;
444
+ expect ( el . find ( '.icon.true ' ) . length ) . toBe ( 1 ) ;
445
+ expect ( el . find ( '.icon.false ' ) . length ) . toBe ( 0 ) ;
419
446
420
447
el . isolateScope ( ) . isTabActive = function ( ) { return false ; } ;
421
448
el . isolateScope ( ) . $apply ( ) ;
422
449
expect ( el . hasClass ( 'active' ) ) . toBe ( false ) ;
423
- expect ( el . find ( '.icon.on ' ) . length ) . toBe ( 0 ) ;
424
- expect ( el . find ( '.icon.off ' ) . length ) . toBe ( 1 ) ;
450
+ expect ( el . find ( '.icon.true ' ) . length ) . toBe ( 0 ) ;
451
+ expect ( el . find ( '.icon.false ' ) . length ) . toBe ( 1 ) ;
425
452
} ) ;
426
453
it ( 'shouldnt has-badge without badge' , function ( ) {
427
454
var el = setup ( ) ;
0 commit comments