Skip to content

Commit

Permalink
Tests: Fix tests for not auto-executing scripts without dataType
Browse files Browse the repository at this point in the history
Two issues are fixed in testing for responses with a script Content-Type not
getting auto-executed unless an explicit `dataType: "script"` is provided:
* the test is now using a correct "text/javascript" Content-Type; it was using
  "text/html" until now which doesn't really check if the fix works
* the Node.js based version of the tests didn't account for an empty `header`
  query string parameter

Closes gh-4824
Ref gh-2432
Ref gh-2588
Ref 39cdb8c

(cherry picked from commit d38528b)
  • Loading branch information
mgol committed Jan 11, 2021
1 parent bcd40aa commit 7298e04
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/middleware-mockserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ var mocks = {
script: function( req, resp ) {
if ( req.query.header === "ecma" ) {
resp.writeHead( 200, { "content-type": "application/ecmascript" } );
} else if ( req.query.header ) {
} else if ( "header" in req.query ) {
resp.writeHead( 200, { "content-type": "text/javascript" } );
} else {
resp.writeHead( 200, { "content-type": "text/html" } );
Expand Down
2 changes: 1 addition & 1 deletion test/unit/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ QUnit.module( "ajax", {
return {
create: function( options ) {
options.crossDomain = true;
return jQuery.ajax( url( "mock.php?action=script" ), options );
return jQuery.ajax( url( "mock.php?action=script&header" ), options );
},
success: function() {
assert.ok( true, "success" );
Expand Down

0 comments on commit 7298e04

Please sign in to comment.