Skip to content

Commit 569d716

Browse files
committed
test(ionCheckbox): add ngChange test
1 parent a006d89 commit 569d716

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

test/unit/angular/directive/checkbox.unit.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff 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
});

0 commit comments

Comments
 (0)