Skip to content

Commit

Permalink
Tests: ensure that module assertions run on supported browsers
Browse files Browse the repository at this point in the history
- Also fixes tests for karma, where the URL for the module is different

Ref gh-3871
  • Loading branch information
timmywil committed Jan 16, 2018
1 parent fa793be commit 625e19c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion test/data/inner_module.js
@@ -1 +1 @@
window.ok( true, "evaluated: innert module with src" ); window.ok( true, "evaluated: inner module with src" );
10 changes: 10 additions & 0 deletions test/data/testinit.js
Expand Up @@ -284,7 +284,17 @@ if ( window.__karma__ ) {
QUnit.isSwarm = ( QUnit.urlParams.swarmURL + "" ).indexOf( "http" ) === 0; QUnit.isSwarm = ( QUnit.urlParams.swarmURL + "" ).indexOf( "http" ) === 0;
QUnit.basicTests = ( QUnit.urlParams.module + "" ) === "basic"; QUnit.basicTests = ( QUnit.urlParams.module + "" ) === "basic";


// Async test for module script type support
function moduleTypeSupported() {
var script = document.createElement( "script" );
script.type = "module";
script.text = "QUnit.moduleTypeSupported = true";
document.head.appendChild( script ).parentNode.removeChild( script );
}
moduleTypeSupported();

this.loadTests = function() { this.loadTests = function() {

// Get testSubproject from testrunner first // Get testSubproject from testrunner first
require( [ "data/testrunner.js" ], function() { require( [ "data/testrunner.js" ], function() {
var i = 0, var i = 0,
Expand Down
22 changes: 14 additions & 8 deletions test/unit/manipulation.js
Expand Up @@ -1797,20 +1797,26 @@ QUnit.test( "html(Function)", function( assert ) {
testHtml( manipulationFunctionReturningObj, assert ); testHtml( manipulationFunctionReturningObj, assert );
} ); } );


QUnit.test( "html(script type module)", function( assert ) { QUnit[ QUnit.moduleTypeSupported ? "test" : "skip" ]( "html(script type module)", function( assert ) {
assert.expect( 1 ); assert.expect( 4 );
var fixture = jQuery( "#qunit-fixture" ), var done = assert.async(),
tmp = fixture.html( $fixture = jQuery( "#qunit-fixture" );

$fixture.html(
[ [
"<script type='module'>ok( true, 'evaluated: module' );</script>", "<script type='module'>ok( true, 'evaluated: module' );</script>",
"<script type='module' src='./data/module.js'></script>", "<script type='module' src='" + url( "module.js" ) + "'></script>",
"<div>", "<div>",
"<script type='module'>ok( true, 'evaluated: inner module' );</script>", "<script type='module'>ok( true, 'evaluated: inner module' );</script>",
"<script type='module' src='./data/inner_module.js'></script>", "<script type='module' src='" + url( "inner_module.js" ) + "'></script>",
"</div>" "</div>"
].join( "" ) ].join( "" )
).find( "script" ); );
assert.equal( tmp.length, 4, "All script tags remain." );
// Allow asynchronous script execution to generate assertions
setTimeout( function() {
done();
}, 1000 );
} ); } );


QUnit.test( "html(Function) with incoming value -- direct selection", function( assert ) { QUnit.test( "html(Function) with incoming value -- direct selection", function( assert ) {
Expand Down

0 comments on commit 625e19c

Please sign in to comment.