Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add test options: minjs, remote, sync (sync not yet functional)
  • Loading branch information
premasagar committed Apr 3, 2013
1 parent 164a0c4 commit 7c51145
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 18 deletions.
19 changes: 1 addition & 18 deletions tests/index.html
Expand Up @@ -23,23 +23,6 @@
<script src="vendor/mocha.js"></script>
<script src="vendor/chai.js"></script>
<script src="vendor/getscript.js"></script>

<script>mocha.setup('bdd')</script>
<script>
// if `?minjs` is used as a query parameter in the browser
var use_min_js = window.location.search.indexOf('minjs') >= 0;

function run(){
mocha.run();
}

getscript(use_min_js ?
'../build/dist/pablo.min.js' :
'../pablo.js',
function(){
getscript('tests.js', run);
}
);
</script>
<script src="testrunner.js"></script>
</body>
</html>
51 changes: 51 additions & 0 deletions tests/testrunner.js
@@ -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));

0 comments on commit 7c51145

Please sign in to comment.