@@ -1241,6 +1241,50 @@ describe("pat-inject", function () {
1241
1241
expect ( pat_ajax . onClickSubmit ) . toHaveBeenCalledTimes ( 1 ) ;
1242
1242
} ) ;
1243
1243
} ) ;
1244
+
1245
+ describe ( "9.2.6 - Support submit buttons without type attribute ..." , ( ) => {
1246
+ it ( "9.2.6.1 - ... without a formaction atttribute." , async function ( ) {
1247
+ document . body . innerHTML = `
1248
+ <form class="pat-inject" action="test.cgi">
1249
+ <button/>
1250
+ </form>
1251
+ ` ;
1252
+
1253
+ const pat_ajax = ( await import ( "../ajax/ajax.js" ) ) . default ;
1254
+ jest . spyOn ( pat_ajax , "onClickSubmit" ) ;
1255
+ jest . spyOn ( pattern , "onFormActionSubmit" ) ;
1256
+
1257
+ const form = document . querySelector ( "form" ) ;
1258
+ const button = form . querySelector ( "button" ) ;
1259
+
1260
+ pattern . init ( $ ( form ) ) ;
1261
+ button . click ( ) ;
1262
+
1263
+ expect ( pat_ajax . onClickSubmit ) . toHaveBeenCalledTimes ( 1 ) ;
1264
+ expect ( pattern . onFormActionSubmit ) . toHaveBeenCalledTimes ( 0 ) ;
1265
+ } ) ;
1266
+
1267
+ it ( "9.2.6.1 - ... with a formaction atttribute." , async function ( ) {
1268
+ document . body . innerHTML = `
1269
+ <form class="pat-inject">
1270
+ <button formaction="test.cgi"/>
1271
+ </form>
1272
+ ` ;
1273
+
1274
+ const pat_ajax = ( await import ( "../ajax/ajax.js" ) ) . default ;
1275
+ jest . spyOn ( pat_ajax , "onClickSubmit" ) ;
1276
+ jest . spyOn ( pattern , "onFormActionSubmit" ) ;
1277
+
1278
+ const form = document . querySelector ( "form" ) ;
1279
+ const button = form . querySelector ( "button" ) ;
1280
+
1281
+ pattern . init ( $ ( form ) ) ;
1282
+ button . click ( ) ;
1283
+
1284
+ expect ( pat_ajax . onClickSubmit ) . toHaveBeenCalledTimes ( 1 ) ;
1285
+ expect ( pattern . onFormActionSubmit ) . toHaveBeenCalledTimes ( 1 ) ;
1286
+ } ) ;
1287
+ } ) ;
1244
1288
} ) ;
1245
1289
} ) ;
1246
1290
0 commit comments