From 569d7165aae56b6ffa02f703f9607bb933d01060 Mon Sep 17 00:00:00 2001 From: Andrew Joslin Date: Tue, 13 May 2014 07:24:32 -0600 Subject: [PATCH] test(ionCheckbox): add ngChange test --- test/unit/angular/directive/checkbox.unit.js | 22 +++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/test/unit/angular/directive/checkbox.unit.js b/test/unit/angular/directive/checkbox.unit.js index 75e12db756d..0d76c4d9262 100644 --- a/test/unit/angular/directive/checkbox.unit.js +++ b/test/unit/angular/directive/checkbox.unit.js @@ -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('')(scope); scope.$apply(); var input = el.find('input'); @@ -52,4 +52,24 @@ describe('Ionic Checkbox', function() { }); + it('should ngChange properly', function() { + el = compile('')(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); + }); + });