11describe ( 'Toggle Switch' , function ( ) {
2- var $scope , $compile ;
2+ var $scope , $compile , isolateScope ;
33
44 var baseTemplate = '<toggle-switch ng-model="switchState">\n</toggle-switch>' ;
5+ var emptyOnLabelTemplate = '<toggle-switch ng-model="switchState" on-label="">\n</toggle-switch>' ;
6+ var emptyOffLabelTemplate = '<toggle-switch ng-model="switchState" off-label="">\n</toggle-switch>' ;
7+ var emptyKnobLabelTemplate = '<toggle-switch ng-model="switchState" knob-label="">\n</toggle-switch>' ;
58 var onLabelTemplate = '<toggle-switch ng-model="switchState" on-label="CUSTOM-ON">\n</toggle-switch>' ;
69 var offLabelTemplate = '<toggle-switch ng-model="switchState" off-label="CUSTOM-OFF">\n</toggle-switch>' ;
710 var knobLabelTemplate = '<toggle-switch ng-model="switchState" knob-label="CUSTOM">\n</toggle-switch>' ;
@@ -22,6 +25,7 @@ describe('Toggle Switch', function() {
2225 var elm = angular . element ( template ) ;
2326 $compile ( elm ) ( scope ) ;
2427 scope . $apply ( ) ;
28+ isolateScope = elm . isolateScope ( ) ;
2529 return elm ;
2630 }
2731
@@ -96,6 +100,13 @@ describe('Toggle Switch', function() {
96100 } ) ;
97101 } ) ;
98102
103+ describe ( 'with an empty `on-label`' , function ( ) {
104+ it ( 'sets the label empty' , function ( ) {
105+ var elm = compileDirective ( emptyOnLabelTemplate , $scope ) ;
106+ expect ( isolateScope . onLabel ) . toEqual ( '' ) ;
107+ } ) ;
108+ } ) ;
109+
99110 describe ( 'when there is a custom `off-label`' , function ( ) {
100111 // @TODO : figure out how to deal with html in Angular 1.2
101112 //describe('is html', function() {
@@ -113,13 +124,27 @@ describe('Toggle Switch', function() {
113124 } ) ;
114125 } ) ;
115126
127+ describe ( 'with an empty `off-label`' , function ( ) {
128+ it ( 'sets the label empty' , function ( ) {
129+ var elm = compileDirective ( emptyOffLabelTemplate , $scope ) ;
130+ expect ( isolateScope . offLabel ) . toEqual ( '' ) ;
131+ } ) ;
132+ } ) ;
133+
116134 describe ( 'when there is a custom `knob-label`' , function ( ) {
117135 it ( 'sets the on label' , function ( ) {
118136 var elm = compileDirective ( knobLabelTemplate , $scope ) ;
119137 expect ( elm . text ( ) ) . toContain ( 'CUSTOM' ) ;
120138 } ) ;
121139 } ) ;
122140
141+ describe ( 'with an empty `knob-label`' , function ( ) {
142+ it ( 'sets the label empty' , function ( ) {
143+ var elm = compileDirective ( emptyKnobLabelTemplate , $scope ) ;
144+ expect ( isolateScope . knobLabel ) . toEqual ( '' ) ;
145+ } ) ;
146+ } ) ;
147+
123148 describe ( 'when toggle is disabled' , function ( ) {
124149 it ( 'ngModel does not change on click' , function ( ) {
125150 $scope . switchState = true ;
0 commit comments