test(ionCheckbox): add ngChange test

This commit is contained in:
Andrew Joslin
2014-05-13 07:24:32 -06:00
parent a006d89612
commit 569d7165aa

View File

@@ -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');
@@ -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);
});
});