Skip to content

Commit

Permalink
test(ionCheckbox): add ngChange test
Browse files Browse the repository at this point in the history
  • Loading branch information
ajoslin committed May 13, 2014
1 parent a006d89 commit 569d716
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion test/unit/angular/directive/checkbox.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('Ionic Checkbox', function() {
expect(input.attr('ng-change')).toBe('change');
});

it('shouhld ngChecked properly', function() {
it('should ngChecked properly', function() {
el = compile('<ion-checkbox ng-checked="shouldCheck">')(scope);
scope.$apply();
var input = el.find('input');
Expand All @@ -52,4 +52,24 @@ describe('Ionic Checkbox', function() {

});

it('should ngChange properly', function() {
el = compile('<ion-checkbox ng-change="change(val)" ng-model="val">')(scope);
scope.change = jasmine.createSpy('change');
scope.$apply();
var input = el.find('input');
var ngModel = input.controller('ngModel');

expect(scope.change).not.toHaveBeenCalled();

ngModel.$setViewValue(true);
scope.$apply();
expect(scope.change).toHaveBeenCalledWith(true);

scope.change.reset();
ngModel.$setViewValue(false);
scope.$apply();

expect(scope.change).toHaveBeenCalledWith(false);
});

});

0 comments on commit 569d716

Please sign in to comment.