mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
test(ionCheckbox): add ngChange test
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user