File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
test/unit/angular/directive Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ describe('Ionic Checkbox', function() {
4040 expect ( input . attr ( 'ng-change' ) ) . toBe ( 'change' ) ;
4141 } ) ;
4242
43- it ( 'shouhld ngChecked properly' , function ( ) {
43+ it ( 'should ngChecked properly' , function ( ) {
4444 el = compile ( '<ion-checkbox ng-checked="shouldCheck">' ) ( scope ) ;
4545 scope . $apply ( ) ;
4646 var input = el . find ( 'input' ) ;
@@ -52,4 +52,24 @@ describe('Ionic Checkbox', function() {
5252
5353 } ) ;
5454
55+ it ( 'should ngChange properly' , function ( ) {
56+ el = compile ( '<ion-checkbox ng-change="change(val)" ng-model="val">' ) ( scope ) ;
57+ scope . change = jasmine . createSpy ( 'change' ) ;
58+ scope . $apply ( ) ;
59+ var input = el . find ( 'input' ) ;
60+ var ngModel = input . controller ( 'ngModel' ) ;
61+
62+ expect ( scope . change ) . not . toHaveBeenCalled ( ) ;
63+
64+ ngModel . $setViewValue ( true ) ;
65+ scope . $apply ( ) ;
66+ expect ( scope . change ) . toHaveBeenCalledWith ( true ) ;
67+
68+ scope . change . reset ( ) ;
69+ ngModel . $setViewValue ( false ) ;
70+ scope . $apply ( ) ;
71+
72+ expect ( scope . change ) . toHaveBeenCalledWith ( false ) ;
73+ } ) ;
74+
5575} ) ;
You can’t perform that action at this time.
0 commit comments