Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add test options: minjs, remote, sync (sync not yet functional)

  • Loading branch information...
commit 7c51145c9c87a992d0ea10f5900e335ad710b515 1 parent 164a0c4
@premasagar authored
Showing with 52 additions and 18 deletions.
  1. +1 −18 tests/index.html
  2. +51 −0 tests/testrunner.js
View
19 tests/index.html
@@ -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>
View
51 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));
Please sign in to comment.
Something went wrong with that request. Please try again.