Code coverage report for lib/process.js

Statements: 94.44% (17 / 18)      Branches: 83.33% (15 / 18)      Functions: 100% (3 / 3)      Lines: 94.44% (17 / 18)     

All files » lib/ » process.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 411   1 2     5 86 66   86 16         2   2 1       2             2     2 2 1   2      
var YUITest = require('yuitest');
 
module.exports = function(results, type) {
    var data = {},
        str = '',
        handle = function(r) {
            Object.keys(r).forEach(function(key) {
                if (!data[key]) {
                    data[key] = r[key];
                }
                if (data[key] && (typeof data[key] === 'number')) {
                    data[key] += r[key];
                }
            });
        };
 
    results.forEach(handle);
 
    if (Array.isArray(results) && results.length === 1) {
        handle(results[0]);
    }
 
    //Fixes #9 - YUITest knows nothing about Istanbul data, so we need to remove it first
    Iif (data.coverage && data.coverageType && data.coverageType === 'istanbul' && type !== 'JSON') {
        delete data.coverage;
    }
    /*
    I know this is bad, but YUITest.TestRunner doesn't allow
    me to add results in a public way, so I have to "work around" it :)
    */
    YUITest.TestRunner._lastResults = data;
 
 
    str = YUITest.TestRunner.getResults(YUITest.TestFormat[type]);
    if (type === 'JSON') {
        str = JSON.stringify(JSON.parse(str), null, 4) + '\n';
    }
    return str;
};