1- describe ( 'tabs' , function ( ) {
1+ ddescribe ( 'tabs' , function ( ) {
22
33 describe ( 'miscellaneous' , function ( ) {
44 beforeEach ( module ( 'ionic' , function ( $provide ) {
@@ -387,10 +387,21 @@ describe('tabs', function() {
387387 expect ( tabsCtrl . select ) . toHaveBeenCalledWith ( tabCtrl . $scope , true ) ;
388388 } ) ;
389389
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 ( ) {
391391 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+
394405 } ) ;
395406
396407 it ( 'should select tab on click' , function ( ) {
@@ -408,20 +419,36 @@ describe('tabs', function() {
408419 el . scope ( ) . $apply ( 'name = "joe"' ) ;
409420 expect ( el . find ( '.tab-title' ) . html ( ) ) . toBe ( '<b>hi, joe!</b>' ) ;
410421 } ) ;
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+ } ) ;
411438 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}}" ' ) ;
413440
414441 el . isolateScope ( ) . isTabActive = function ( ) { return true ; } ;
415442 el . isolateScope ( ) . $apply ( ) ;
416443 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 ) ;
419446
420447 el . isolateScope ( ) . isTabActive = function ( ) { return false ; } ;
421448 el . isolateScope ( ) . $apply ( ) ;
422449 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 ) ;
425452 } ) ;
426453 it ( 'shouldnt has-badge without badge' , function ( ) {
427454 var el = setup ( ) ;
0 commit comments