All files / universal/gpii/node_modules/matchMakerFramework/test/js InverseCapabilitiesTests.js

100% Statements 19/19
75% Branches 3/4
100% Functions 5/5
100% Lines 19/19

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                                    2x 2x   2x     2x   2x 30x           30x 30x     2x           2x                                       2x 2x 12x   12x 12x 12x       2x 2x 2x      
/**
GPII MatchMaker Inverse Capabilities Tests
 
Copyright 2013 OCAD University
Copyright 2014, 2016 Raising The Floor - International
 
Licensed under the New BSD license. You may not use this file except in
compliance with this License.
 
The research leading to these results has received funding from the European Union's
Seventh Framework Programme (FP7/2007-2013) under grant agreement no. 289016.
 
You may obtain a copy of the License at
https://github.com/GPII/universal/blob/master/LICENSE.txt
*/
 
/* global $, jqUnit, JSON5 */
 
var fluid = fluid || require("infusion");
var gpii = fluid.registerNamespace("gpii");
 
(function () {
    "use strict";
 
    fluid.registerNamespace("gpii.tests.matchMakerFramework.inverse");
 
    gpii.tests.matchMakerFramework.inverse.loadJSON = function (url) {
        var content = $.ajax({
            type: "GET",
            url: url,
            async: false
        }).responseText;
 
        var parser = (url.substring(url.length - 5).toLowerCase() === ".json") ? JSON : JSON5;
        return parser.parse(content);
    };
 
    gpii.tests.matchMakerFramework.inverse.fullSolutionsRegistry = {
        win32: gpii.tests.matchMakerFramework.inverse.loadJSON("../../../../../testData/solutions/win32.json5"),
        linux: gpii.tests.matchMakerFramework.inverse.loadJSON("../../../../../testData/solutions/linux.json5"),
        android: gpii.tests.matchMakerFramework.inverse.loadJSON("../../../../../testData/solutions/android.json5")
    };
 
    var testDefs = [{
        name: "os_win7 inversion",
        token: "os_win7"
    }, {
        name: "os_gnome inversion - combination of explicit and automatic inversions",
        token: "os_gnome"
    }, {
        name: "os_common inversion - no inversion happenening",
        token: "os_common"
    }, {
        name: "os_android inversion - no explicit inverses given",
        token: "os_android"
    }, {
        name: "jaws_application inversion - no explicit inverses given",
        token: "jaws_application"
    }, {
        name: "scoped_common_magnifier - scoped common terms are 'inferred' as well",
        token: "scoped_common_magnifier"
    }];
 
    gpii.tests.matchMakerFramework.inverse.testCommonTermsInference = function () {
        fluid.each(testDefs, function (def) {
            var prefs = gpii.tests.matchMakerFramework.inverse.loadJSON("../../../../../testData/preferences/acceptanceTests/" +
                    def.token + ".json");
            var result = gpii.matchMakerFramework.utils.inferCommonTerms(prefs.flat, gpii.tests.matchMakerFramework.inverse.fullSolutionsRegistry);
            var expected = gpii.tests.matchMakerFramework.inverse.loadJSON("../inverseCapabilities/" + def.token + "_expected.json");
            jqUnit.assertDeepEq("Expected inversion for capabilities transformation - " + def.name, expected, result);
        });
    };
 
    gpii.tests.matchMakerFramework.inverse.runTests = function () {
        jqUnit.module("MatchMakerUtilities");
        jqUnit.test("Check inverses", gpii.tests.matchMakerFramework.inverse.testCommonTermsInference);
    };
})();