diff options
| author | Vojta Jina | 2012-02-27 16:28:12 -0800 |
|---|---|---|
| committer | Vojta Jina | 2012-02-28 18:22:41 -0800 |
| commit | 4370d756e4e758f0e95e83390f7555cb9f48e6fe (patch) | |
| tree | b899b73c22ede0c3858faba346b51ecbf8096222 /test/widget | |
| parent | 4e83399570391fe4a41ce4dc27c8a191f761d26d (diff) | |
| download | angular.js-4370d756e4e758f0e95e83390f7555cb9f48e6fe.tar.bz2 | |
refactor(directive.ngModel): rename emitValidity -> setValidity
Diffstat (limited to 'test/widget')
| -rw-r--r-- | test/widget/formSpec.js | 18 | ||||
| -rw-r--r-- | test/widget/inputSpec.js | 24 |
2 files changed, 21 insertions, 21 deletions
diff --git a/test/widget/formSpec.js b/test/widget/formSpec.js index bc5f3ea7..6387241f 100644 --- a/test/widget/formSpec.js +++ b/test/widget/formSpec.js @@ -38,7 +38,7 @@ describe('form', function() { '</form>')(scope); var form = scope.form; - widget.emitValidity('REQUIRED', false); + widget.setValidity('REQUIRED', false); expect(form.alias).toBe(widget); expect(form.error.REQUIRED).toEqual([widget]); @@ -107,11 +107,11 @@ describe('form', function() { var child = scope.child; var input = child.text; - input.emitValidity('MyError', false); + input.setValidity('MyError', false); expect(parent.error.MyError).toEqual([input]); expect(child.error.MyError).toEqual([input]); - input.emitValidity('MyError', true); + input.setValidity('MyError', true); expect(parent.error.MyError).toBeUndefined(); expect(child.error.MyError).toBeUndefined(); }); @@ -138,12 +138,12 @@ describe('form', function() { expect(child).toBeDefined(); expect(input).toBeDefined(); - input.emitValidity('myRule', false); + input.setValidity('myRule', false); expect(input.error.myRule).toEqual(true); expect(child.error.myRule).toEqual([input]); expect(parent.error.myRule).toEqual([input]); - input.emitValidity('myRule', true); + input.setValidity('myRule', true); expect(parent.error.myRule).toBeUndefined(); expect(child.error.myRule).toBeUndefined(); }); @@ -177,18 +177,18 @@ describe('form', function() { it('should have ng-valid/ng-invalid css class', function() { expect(doc).toBeValid(); - widget.emitValidity('ERROR', false); + widget.setValidity('ERROR', false); scope.$apply(); expect(doc).toBeInvalid(); - widget.emitValidity('ANOTHER', false); + widget.setValidity('ANOTHER', false); scope.$apply(); - widget.emitValidity('ERROR', true); + widget.setValidity('ERROR', true); scope.$apply(); expect(doc).toBeInvalid(); - widget.emitValidity('ANOTHER', true); + widget.setValidity('ANOTHER', true); scope.$apply(); expect(doc).toBeValid(); }); diff --git a/test/widget/inputSpec.js b/test/widget/inputSpec.js index 69baba06..d9f6b7b3 100644 --- a/test/widget/inputSpec.js +++ b/test/widget/inputSpec.js @@ -49,44 +49,44 @@ describe('NgModelController', function() { }); - describe('emitValidity', function() { + describe('setValidity', function() { it('should emit $invalid only when $valid', function() { var spy = jasmine.createSpy('$invalid'); scope.$on('$invalid', spy); - ctrl.emitValidity('ERROR', false); + ctrl.setValidity('ERROR', false); expect(spy).toHaveBeenCalledOnce(); spy.reset(); - ctrl.emitValidity('ERROR', false); + ctrl.setValidity('ERROR', false); expect(spy).not.toHaveBeenCalled(); }); it('should set and unset the error', function() { - ctrl.emitValidity('REQUIRED', false); + ctrl.setValidity('REQUIRED', false); expect(ctrl.error.REQUIRED).toBe(true); - ctrl.emitValidity('REQUIRED', true); + ctrl.setValidity('REQUIRED', true); expect(ctrl.error.REQUIRED).toBeUndefined(); }); it('should set valid/invalid', function() { - ctrl.emitValidity('FIRST', false); + ctrl.setValidity('FIRST', false); expect(ctrl.valid).toBe(false); expect(ctrl.invalid).toBe(true); - ctrl.emitValidity('SECOND', false); + ctrl.setValidity('SECOND', false); expect(ctrl.valid).toBe(false); expect(ctrl.invalid).toBe(true); - ctrl.emitValidity('SECOND', true); + ctrl.setValidity('SECOND', true); expect(ctrl.valid).toBe(false); expect(ctrl.invalid).toBe(true); - ctrl.emitValidity('FIRST', true); + ctrl.setValidity('FIRST', true); expect(ctrl.valid).toBe(true); expect(ctrl.invalid).toBe(false); }); @@ -96,11 +96,11 @@ describe('NgModelController', function() { var spy = jasmine.createSpy('$valid'); scope.$on('$valid', spy); - ctrl.emitValidity('ERROR', true); + ctrl.setValidity('ERROR', true); expect(spy).not.toHaveBeenCalled(); - ctrl.emitValidity('ERROR', false); - ctrl.emitValidity('ERROR', true); + ctrl.setValidity('ERROR', false); + ctrl.setValidity('ERROR', true); expect(spy).toHaveBeenCalledOnce(); }); }); |
