@@ -64,36 +64,6 @@ describe('form', function() {
64
64
} ) ;
65
65
66
66
67
- it ( 'should prevent form submission' , function ( ) {
68
- var startingUrl = '' + window . location ;
69
- doc = jqLite ( '<form name="myForm"><input type="submit" value="submit" />' ) ;
70
- $compile ( doc ) ( scope ) ;
71
-
72
- browserTrigger ( doc . find ( 'input' ) ) ;
73
- waitsFor (
74
- function ( ) { return true ; } ,
75
- 'let browser breath, so that the form submision can manifest itself' , 10 ) ;
76
-
77
- runs ( function ( ) {
78
- expect ( '' + window . location ) . toEqual ( startingUrl ) ;
79
- } ) ;
80
- } ) ;
81
-
82
-
83
- it ( 'should not prevent form submission if action attribute present' , function ( ) {
84
- var callback = jasmine . createSpy ( 'submit' ) . andCallFake ( function ( event ) {
85
- expect ( event . isDefaultPrevented ( ) ) . toBe ( false ) ;
86
- event . preventDefault ( ) ;
87
- } ) ;
88
-
89
- doc = $compile ( '<form name="x" action="some.py" />' ) ( scope ) ;
90
- doc . bind ( 'submit' , callback ) ;
91
-
92
- browserTrigger ( doc , 'submit' ) ;
93
- expect ( callback ) . toHaveBeenCalledOnce ( ) ;
94
- } ) ;
95
-
96
-
97
67
it ( 'should publish form to scope when name attr is defined' , function ( ) {
98
68
doc = $compile ( '<form name="myForm"></form>' ) ( scope ) ;
99
69
expect ( scope . myForm ) . toBeTruthy ( ) ;
@@ -155,6 +125,39 @@ describe('form', function() {
155
125
} ) ;
156
126
157
127
128
+ describe ( 'preventing default submission' , function ( ) {
129
+
130
+ it ( 'should prevent form submission' , function ( ) {
131
+ var startingUrl = '' + window . location ;
132
+ doc = jqLite ( '<form name="myForm"><input type="submit" value="submit" />' ) ;
133
+ $compile ( doc ) ( scope ) ;
134
+
135
+ browserTrigger ( doc . find ( 'input' ) ) ;
136
+ waitsFor (
137
+ function ( ) { return true ; } ,
138
+ 'let browser breath, so that the form submission can manifest itself' , 10 ) ;
139
+
140
+ runs ( function ( ) {
141
+ expect ( '' + window . location ) . toEqual ( startingUrl ) ;
142
+ } ) ;
143
+ } ) ;
144
+
145
+
146
+ it ( 'should not prevent form submission if action attribute present' , function ( ) {
147
+ var callback = jasmine . createSpy ( 'submit' ) . andCallFake ( function ( event ) {
148
+ expect ( event . isDefaultPrevented ( ) ) . toBe ( false ) ;
149
+ event . preventDefault ( ) ;
150
+ } ) ;
151
+
152
+ doc = $compile ( '<form name="x" action="some.py" />' ) ( scope ) ;
153
+ doc . bind ( 'submit' , callback ) ;
154
+
155
+ browserTrigger ( doc , 'submit' ) ;
156
+ expect ( callback ) . toHaveBeenCalledOnce ( ) ;
157
+ } ) ;
158
+ } ) ;
159
+
160
+
158
161
describe ( 'nested forms' , function ( ) {
159
162
160
163
it ( 'should chain nested forms' , function ( ) {
0 commit comments