Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add test options: minjs, remote, sync (sync not yet functional)
- Loading branch information
1 parent
164a0c4
commit 7c51145
Showing
2 changed files
with
52 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
(function(window){ | ||
'use strict'; | ||
|
||
function run(){ | ||
mocha.run(); | ||
} | ||
// if `?minjs` is used as a query parameter in the browser | ||
// Use query parameters in the test page's URL to direct which version of | ||
// Pablo is being tested | ||
var search = window.location.search, | ||
minjs = window.PABLO_MINJS || /\bminjs\b/.test(search), | ||
remote = window.PABLO_REMOTE || /\bremote\b/.test(search), | ||
sync = window.PABLO_SYNC || /\bsync\b/.test(search), | ||
testsSrc = 'tests.js', | ||
pabloSrc; | ||
|
||
// Setup Mocha | ||
mocha.setup('bdd'); | ||
|
||
// Test pablo.min.js - either remote or local | ||
if (minjs){ | ||
pabloSrc = remote ? | ||
'http://pablojs.com/downloads/pablo.min.js' : | ||
'../build/dist/pablo.min.js'; | ||
} | ||
|
||
// Test pablo.js - either remote or local | ||
else { | ||
pabloSrc = remote ? | ||
'http://pablojs.com/downloads/pablo.js' : | ||
'../pablo.js'; | ||
} | ||
|
||
// Load the script to be tested | ||
|
||
// Synchronously (not yet functional) | ||
if (sync){ | ||
document.write( | ||
'<script src="' + pabloSrc + '"><\/script>' + | ||
'<script src="' + testsSrc + '"><\/script>' | ||
); | ||
run(); | ||
} | ||
|
||
// Asynchronously | ||
else { | ||
getscript(pabloSrc, function(){ | ||
getscript(testsSrc, run); | ||
}); | ||
} | ||
}(this)); |