Code coverage report for istanbul/lib/report/common/defaults.js

Statements: 100% (20 / 20)      Branches: 100% (11 / 11)      Functions: 100% (5 / 5)      Lines: 100% (17 / 17)      Ignored: 7 statements, 4 branches     

All files » istanbul/lib/report/common/ » defaults.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 41 42 43 44 45 46 47 48 49          89   89   623                 168   168         183 1 1 1 1     183       95 95 1045   1045 760     95        
/*
 Copyright (c) 2013, Yahoo! Inc.  All rights reserved.
 Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
 */
 
var Report  = require('../index');
 
module.exports = {
    watermarks: function () {
        return {
            statements: [ 50, 80 ],
            lines: [ 50, 80 ],
            functions: [ 50, 80],
            branches: [ 50, 80 ]
        };
    },
 
    classFor: function (type, metrics, watermarks) {
        var mark = watermarks[type],
            value = metrics[type].pct;
        return value >= mark[1] ? 'high' : value >= mark[0] ? 'medium' : 'low';
    },
 
    colorize: function (str, clazz) {
        /* istanbul ignore if: untestable in batch mode */
        Iif (process.stdout.isTTY) {
            switch (clazz) {
                case 'low' : str = '\033[91m' + str + '\033[0m'; break;
                case 'medium': str = '\033[93m' + str + '\033[0m'; break;
                case 'high': str = '\033[92m' + str + '\033[0m'; break;
            }
        }
        return str;
    },
 
    defaultReportConfig: function () {
        var cfg = {};
        Report.getReportList().forEach(function (type) {
            var rpt = Report.create(type),
                c = rpt.getDefaultConfig();
            if (c) {
                cfg[type] = c;
            }
        });
        return cfg;
    }
};