All files / universal/gpii/node_modules/processReporter/test/web/js ProcessReporterTests.js

100% Statements 13/13
100% Branches 0/0
100% Functions 5/5
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106                                2x 2x   2x         2x 12x     2x         2x 6x     2x                                                                                                                         2x 2x 14x 14x        
/*
 * Process Reporter Tests
 *
 * Copyright 2017 Raising the Floor - International
 *
 * Licensed under the New BSD license. You may not use this file except in
 * compliance with this License.
 *
 * You may obtain a copy of the License at
 * https://github.com/GPII/universal/blob/master/LICENSE.txt
 */
 
/* global fluid, jqUnit, gpii */
 
"use strict";
 
(function () {
    fluid.registerNamespace("gpii.tests.processReporter");
 
    fluid.defaults("gpii.tests.processReporter.alwaysTrue", {
        gradeNames: "fluid.function",
        argumentMap: {}
    });
 
    gpii.tests.processReporter.alwaysTrue = function () {
        return true;
    };
 
    fluid.defaults("gpii.tests.processReporter.alwaysFalse", {
        gradeNames: "fluid.function",
        argumentMap: {}
    });
 
    gpii.tests.processReporter.alwaysFalse = function () {
        return false;
    };
 
    gpii.tests.processReporter.handleIsRunningSpecs = {
        "No isRunning block": {
            input: {},
            expected: undefined
        },
        "Single true entry as object": {
            input: {
                isRunning: {
                    "type": "gpii.tests.processReporter.alwaysTrue"
                }
            },
            expected: true
        },
        "Single true entry as array": {
            input: {
                isRunning: [{
                    "type": "gpii.tests.processReporter.alwaysTrue"
                }]
            },
            expected: true
        },
        "Single false entry": {
            input: {
                isRunning: [{
                    "type": "gpii.tests.processReporter.alwaysFalse"
                }]
            },
            expected: false
        },
        "true + false => false": {
            input: {
                isRunning: [{
                    "type": "gpii.tests.processReporter.alwaysTrue"
                }, {
                    "type": "gpii.tests.processReporter.alwaysFalse"
                }]
            },
            expected: false
        },
        "false + true => false": {
            input: {
                isRunning: [{
                    "type": "gpii.tests.processReporter.alwaysFalse"
                }, {
                    "type": "gpii.tests.processReporter.alwaysTrue"
                }]
            },
            expected: false
        },
        "true + true => true": {
            input: {
                isRunning: [{
                    "type": "gpii.tests.processReporter.alwaysTrue"
                }, {
                    "type": "gpii.tests.processReporter.alwaysTrue"
                }]
            },
            expected: true
        }
    };
 
    jqUnit.test("gpii.processReporter.handleIsRunning tests", function () {
        fluid.each(gpii.tests.processReporter.handleIsRunningSpecs, function (spec, title) {
            var actual = gpii.processReporter.handleIsRunning(spec.input);
            jqUnit.assertEquals(title, spec.expected, actual);
        });
    });
})();