Skip to content
Permalink
Browse files

Tests: ensure that module assertions run on supported browsers

- 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 625e19cd9be4898939a7c40dbeb2b17e40df9d54
Showing with 25 additions and 9 deletions.
  1. +1 −1 test/data/inner_module.js
  2. +10 −0 test/data/testinit.js
  3. +14 −8 test/unit/manipulation.js
@@ -1 +1 @@
window.ok( true, "evaluated: innert module with src" );
window.ok( true, "evaluated: inner module with src" );
@@ -284,7 +284,17 @@ if ( window.__karma__ ) {
QUnit.isSwarm = ( QUnit.urlParams.swarmURL + "" ).indexOf( "http" ) === 0;
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() {

// Get testSubproject from testrunner first
require( [ "data/testrunner.js" ], function() {
var i = 0,
@@ -1797,20 +1797,26 @@ QUnit.test( "html(Function)", function( assert ) {
testHtml( manipulationFunctionReturningObj, assert );
} );

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

$fixture.html(
[
"<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>",
"<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>"
].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 ) {

0 comments on commit 625e19c

Please sign in to comment.
You can’t perform that action at this time.