diff options
| author | Vojta Jina | 2012-03-12 01:24:43 -0700 |
|---|---|---|
| committer | Vojta Jina | 2012-03-12 01:40:12 -0700 |
| commit | 1b9277bf6f16f714bba418dd5a7bf719206fe4d6 (patch) | |
| tree | 81c527a4401504fbdba4c87b9db3ea4ebcdceb65 /test/directive | |
| parent | cce31d4c93978a9b2ed3bddb5f16e22fa0d07f5b (diff) | |
| download | angular.js-1b9277bf6f16f714bba418dd5a7bf719206fe4d6.tar.bz2 | |
fix(forms): Propagate change from model even if it's undefined
Diffstat (limited to 'test/directive')
| -rw-r--r-- | test/directive/inputSpec.js | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/test/directive/inputSpec.js b/test/directive/inputSpec.js index 6298fc64..653dfdc6 100644 --- a/test/directive/inputSpec.js +++ b/test/directive/inputSpec.js @@ -183,22 +183,32 @@ describe('NgModelController', function() { }); - it('should $render only if value changed and is valid', function() { + it('should $render only if value changed', function() { spyOn(ctrl, 'render'); scope.$apply(function() { - scope.value= 3; + scope.value = 3; }); expect(ctrl.render).toHaveBeenCalledOnce(); ctrl.render.reset(); - // invalid - ctrl.formatters.push(function() {return undefined;}); + ctrl.formatters.push(function() {return 3;}); scope.$apply(function() { - scope.value= 5; + scope.value = 5; }); expect(ctrl.render).not.toHaveBeenCalled(); }); + + + it('should clear the view even if invalid', function() { + spyOn(ctrl, 'render'); + + ctrl.formatters.push(function() {return undefined;}); + scope.$apply(function() { + scope.value = 5; + }); + expect(ctrl.render).toHaveBeenCalledOnce(); + }); }); }); @@ -729,6 +739,19 @@ describe('input', function() { browserTrigger(inputElm, 'click'); expect(scope.name).toEqual('n'); }); + + + it('should be required if false', function() { + compileInput('<input type="checkbox" ng:model="value" required />'); + + browserTrigger(inputElm, 'click'); + expect(inputElm[0].checked).toBe(true); + expect(inputElm).toBeValid(); + + browserTrigger(inputElm, 'click'); + expect(inputElm[0].checked).toBe(false); + expect(inputElm).toBeInvalid(); + }); }); |
