Skip to content

Commit

Permalink
Tests: Avoid loosen errors on autostart test
Browse files Browse the repository at this point in the history
Also remove the QUnit.load as they were invalid

Fixes #798
Closes #803
  • Loading branch information
leobalter committed Apr 16, 2015
1 parent 1b7953b commit 2c14c6b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
1 change: 1 addition & 0 deletions browserstack.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"test/logs.html",
"test/setTimeout.html",
"test/amd.html",
"test/autostart.html",
"test/reporter-html/index.html"
],
"browsers": [
Expand Down
17 changes: 4 additions & 13 deletions test/autostart.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,27 @@
<script src="../dist/qunit.js"></script>
<script>
var beginData,
asyncDelay = 1000,
times = {
autostartOff: 0,
pageLoaded: 0,
runStarted: 0
};
times = {};

(function() {
var now = Date.now || function() {
return new Date().getTime();
};
var asyncDelay = 1000;

QUnit.config.autostart = false;

// Mark the current time
times.autostartOff = now();
times.autostartOff = now() + asyncDelay;

// Simulate a delay in loading the tests, as when they are loaded
// asynchronously using requirejs, steal, etc.
setTimeout(function() {
var script = document.createElement( "script" );
script.src = "autostart.js";
document.getElementsByTagName( "head" )[0].appendChild( script );
document.getElementsByTagName( "head" )[ 0 ].appendChild( script );
}, asyncDelay );

QUnit.load = (function( _load ) {
times.pageLoaded = now();
_load.call( QUnit );
})( QUnit.load );

QUnit.begin(function( data ) {
beginData = data;
times.runStarted = now();
Expand Down
8 changes: 3 additions & 5 deletions test/autostart.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
/*global asyncDelay, times, beginData */
/*global times, beginData */

QUnit.start();

QUnit.module( "autostart" );

QUnit.test( "Prove the test run started as expected", function( assert ) {
assert.expect( 4 );
assert.ok( times.autostartOff <= times.pageLoaded );
assert.ok( times.pageLoaded <= times.runStarted );
assert.ok( times.autostartOff + asyncDelay <= times.runStarted );
assert.expect( 2 );
assert.ok( times.autostartOff <= times.runStarted );
assert.strictEqual( beginData.totalTests, 1, "Should have expected 1 test" );
});

0 comments on commit 2c14c6b

Please sign in to comment.