mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-05 21:54:42 +00:00
refactor(formSpec): group preventDefault specs into a describe
This commit is contained in:
parent
07c354a8c0
commit
6b75475ce3
1 changed files with 33 additions and 30 deletions
|
|
@ -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() {
|
it('should publish form to scope when name attr is defined', function() {
|
||||||
doc = $compile('<form name="myForm"></form>')(scope);
|
doc = $compile('<form name="myForm"></form>')(scope);
|
||||||
expect(scope.myForm).toBeTruthy();
|
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() {
|
describe('nested forms', function() {
|
||||||
|
|
||||||
it('should chain nested forms', function() {
|
it('should chain nested forms', function() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue