diff options
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(); + }); }); |
