Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Commit

Permalink
improving tests to work well both in node and browser, per #113
Browse files Browse the repository at this point in the history
  • Loading branch information
getify committed Apr 4, 2017
1 parent 436380b commit 693a512
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"devDependencies": {
"freshy": "~1.0.2",
"mock-dom-resources": "~5.0.0",
"mock-dom-resources": "~7.0.0",
"qunitjs": "~2.3.0",
"stable-timers": "~1.0.0",
"uglify-js": "~2.8.21"
Expand Down
1 change: 0 additions & 1 deletion scripts/node-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ require("stable-timers").replaceGlobals();

global.$DOM = require("mock-dom-resources");


global.get$LAB = get$LAB;

require("../tests/qunit.config.js");
Expand Down
7 changes: 3 additions & 4 deletions tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ QUnit.test( "load a script", function test(assert){

var { logs, log, error } = collectLogs();

// only replace globals in node (fails in browser)
$DOM.replaceGlobals = (typeof window == "undefined");
$DOM( {
replaceGlobals: true,
sequentialIds: true,
log,
error,
location: "http://some.tld/",
resources: [
{ url: "http://some.tld/a.js", preloadDelay: 10, preload: true, loadDelay: 5, load: true }
]
Expand All @@ -21,10 +19,11 @@ QUnit.test( "load a script", function test(assert){
var $LAB = get$LAB();

$LAB
.setOptions( {BasePath: "http://some.tld/"} )
.script( "a.js" )
.wait( function(){
$DOM.restoreGlobals();
assert.ok( true, "a.js" );
// console.log(logs);
done();
} );
} );
Expand Down

0 comments on commit 693a512

Please sign in to comment.