diff options
| author | Igor Minar | 2012-08-07 17:23:16 -0700 | 
|---|---|---|
| committer | Igor Minar | 2012-08-10 14:20:28 -0700 | 
| commit | 6b75475ce3e3ab03570b500461c869386f4fc84d (patch) | |
| tree | e62809c165735f8447dab2a00bc12e57fb9f96db /test | |
| parent | 07c354a8c0f4889fa8e0227d865ae3cf8a0adb19 (diff) | |
| download | angular.js-6b75475ce3e3ab03570b500461c869386f4fc84d.tar.bz2 | |
refactor(formSpec): group preventDefault specs into a describe
Diffstat (limited to 'test')
| -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() {  | 
