diff options
| author | Igor Minar | 2012-08-07 17:23:16 -0700 |
|---|---|---|
| committer | Igor Minar | 2012-08-07 17:23:16 -0700 |
| commit | c25cb7d48872fbb37b68f57c9c493ed8bb86a140 (patch) | |
| tree | 46ae99028b7d569e54551b5f0565b8745739a053 /test/ng/directive/formSpec.js | |
| parent | 54e4a6ffbf9de21d33bc9f770db93677590d148a (diff) | |
| download | angular.js-c25cb7d48872fbb37b68f57c9c493ed8bb86a140.tar.bz2 | |
refactor(formSpec): group preventDefault specs into a describe
Diffstat (limited to 'test/ng/directive/formSpec.js')
| -rw-r--r-- | test/ng/directive/formSpec.js | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/test/ng/directive/formSpec.js b/test/ng/directive/formSpec.js index 8b87f266..fa047480 100644 --- a/test/ng/directive/formSpec.js +++ b/test/ng/directive/formSpec.js @@ -64,36 +64,6 @@ describe('form', function() { }); - it('should prevent form submission', function() { - var startingUrl = '' + window.location; - doc = jqLite('<form name="myForm"><input type="submit" value="submit" />'); - $compile(doc)(scope); - - browserTrigger(doc.find('input')); - waitsFor( - function() { return true; }, - 'let browser breath, so that the form submision can manifest itself', 10); - - runs(function() { - expect('' + window.location).toEqual(startingUrl); - }); - }); - - - it('should not prevent form submission if action attribute present', function() { - var callback = jasmine.createSpy('submit').andCallFake(function(event) { - expect(event.isDefaultPrevented()).toBe(false); - event.preventDefault(); - }); - - doc = $compile('<form name="x" action="some.py" />')(scope); - doc.bind('submit', callback); - - browserTrigger(doc, 'submit'); - expect(callback).toHaveBeenCalledOnce(); - }); - - it('should publish form to scope when name attr is defined', function() { doc = $compile('<form name="myForm"></form>')(scope); expect(scope.myForm).toBeTruthy(); @@ -155,6 +125,39 @@ describe('form', function() { }); + describe('preventing default submission', function() { + + it('should prevent form submission', function() { + var startingUrl = '' + window.location; + doc = jqLite('<form name="myForm"><input type="submit" value="submit" />'); + $compile(doc)(scope); + + browserTrigger(doc.find('input')); + waitsFor( + function() { return true; }, + 'let browser breath, so that the form submission can manifest itself', 10); + + runs(function() { + expect('' + window.location).toEqual(startingUrl); + }); + }); + + + it('should not prevent form submission if action attribute present', function() { + var callback = jasmine.createSpy('submit').andCallFake(function(event) { + expect(event.isDefaultPrevented()).toBe(false); + event.preventDefault(); + }); + + doc = $compile('<form name="x" action="some.py" />')(scope); + doc.bind('submit', callback); + + browserTrigger(doc, 'submit'); + expect(callback).toHaveBeenCalledOnce(); + }); + }); + + describe('nested forms', function() { it('should chain nested forms', function() { |
