Skip to content

Commit

Permalink
Test: Refactor startError test to not reload QUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
trentmwillis committed Mar 2, 2018
1 parent 1769c3e commit dfe4cfc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 28 deletions.
22 changes: 0 additions & 22 deletions test/startError.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,6 @@
<body>
<div id="qunit"></div>
<script src="../dist/qunit.js"></script>
<script>

try {
QUnit.config.autostart = true;
QUnit.start();
} catch ( thrownError ) {
window.autostartStartError = thrownError;
}

try {
QUnit.start();
} catch ( thrownError ) {
window.tooManyStartsError = thrownError;
}

// Delete QUnit global so we can reload it
delete window.QUnit;
</script>

<!-- INTENTIONALLY reload QUnit -->
<script src="../dist/qunit.js"></script>

<script src="startError.js"></script>
</body>
</html>
24 changes: 18 additions & 6 deletions test/startError.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
try {
QUnit.config.autostart = true;
QUnit.start();
} catch ( thrownError ) {
window.autostartStartError = thrownError;
}

try {
QUnit.start();
} catch ( thrownError ) {
window.tooManyStartsError = thrownError;
}

QUnit.module( "global start unrecoverable errors" );

QUnit.test( "start() throws when QUnit.config.autostart === true", function( assert ) {
Expand All @@ -6,9 +19,8 @@ QUnit.test( "start() throws when QUnit.config.autostart === true", function( ass
"Called start() outside of a test context when QUnit.config.autostart was true" );
} );

QUnit.test( "Throws after calling start() too many times outside of a test context",
function( assert ) {
assert.expect( 1 );
assert.equal( window.tooManyStartsError.message,
"Called start() outside of a test context too many times" );
} );
QUnit.test( "Throws after calling start() too many times outside of a test context", function( assert ) {
assert.expect( 1 );
assert.equal( window.tooManyStartsError.message,
"Called start() outside of a test context too many times" );
} );

0 comments on commit dfe4cfc

Please sign in to comment.