Home | History | Annotate | Download | only in src
      1 (function(){
      2 if (typeof QUnit !== 'undefined'){
      3     var QUnitAutostart = (QUnit.config.autostart === undefined) ? true : QUnit.config.autostart;
      4 
      5     //check to make sure requirejs is completed before we start the test runner
      6     var allLoaded = function() {
      7         return window.QUnit.config.queue.length > 0 && blanket.noConflict().requireFilesLoaded();
      8     };
      9 
     10     function shouldAutoStart() {
     11         return !(blanket.options("existingRequireJS") && !blanket.options("autoStart")) && QUnitAutostart;
     12     }
     13 
     14     if (!QUnit.config.urlConfig[0].tooltip){
     15         //older versions we run coverage automatically
     16         //and we change how events are binded
     17         QUnit.begin=function(){
     18             blanket.noConflict().setupCoverage();
     19         };
     20 
     21         QUnit.done=function(failures, total) {
     22             blanket.noConflict().onTestsDone();
     23         };
     24         QUnit.moduleStart=function( details ) {
     25             blanket.noConflict().onModuleStart();
     26         };
     27         QUnit.testStart=function( details ) {
     28             blanket.noConflict().onTestStart();
     29         };
     30         QUnit.testDone=function( details ) {
     31             blanket.noConflict().onTestDone(details.total,details.passed);
     32         };
     33         blanket.beforeStartTestRunner({
     34             condition: allLoaded,
     35             callback: QUnit.start
     36         });
     37     }else{
     38         QUnit.config.urlConfig.push({
     39             id: "coverage",
     40             label: "Enable coverage",
     41             tooltip: "Enable code coverage."
     42         });
     43 
     44         if ( QUnit.urlParams.coverage || blanket.options("autoStart") ) {
     45             QUnit.config.autostart = false;
     46             QUnit.begin(function(){
     47                 blanket.noConflict().setupCoverage();
     48             });
     49 
     50             QUnit.done(function(failures, total) {
     51                 blanket.noConflict().onTestsDone();
     52             });
     53             QUnit.moduleStart(function( details ) {
     54                 blanket.noConflict().onModuleStart();
     55             });
     56             QUnit.testStart(function( details ) {
     57                 blanket.noConflict().onTestStart();
     58             });
     59             QUnit.testDone(function( details ) {
     60                 blanket.noConflict().onTestDone(details.total,details.passed);
     61             });
     62             blanket.noConflict().beforeStartTestRunner({
     63                 condition: allLoaded,
     64                 callback: function(){
     65                     if (shouldAutoStart()){
     66                         QUnit.start();
     67                     }
     68                 }
     69             });
     70         }
     71     }
     72 }
     73 })();