All files / universal.klown/gpii/node_modules/testing/src CloudBased.js

100% Statements 28/28
100% Branches 4/4
100% Functions 8/8
100% Lines 28/28

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                                        1x 1x 1x 1x   1x   1x 20x 20x       1x 31x           31x 53x   31x     1x                                           1x 35x           1x     20x 20x 20x 20x 20x   20x             20x   20x     1x 8x 20x      
/*!
GPII Cloud-based Flow Manager Test Infrastructure
 
Copyright 2012 OCAD University
Copyright 2012 Antranig Basman
Copyright 2013 Raising the Floor
Copyright 2014 Lucendo Development Ltd.
 
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
*/
 
"use strict";
 
var fluid = require("infusion"),
    gpii = fluid.registerNamespace("gpii"),
    jqUnit = fluid.registerNamespace("jqUnit"),
    kettle = fluid.registerNamespace("kettle");
 
fluid.registerNamespace("gpii.test.cloudBased");
 
gpii.test.cloudBased.FMRequestListenerMaker = function (expected) {
    return function (data) {
        jqUnit.assertDeepEq("Checking the returned data from the flowmanager: ", expected, JSON.parse(data));
    };
};
 
gpii.test.cloudBased.computeDevice = function (solutionIds, OSid) {
    var device = {
        OS: {
            id: OSid || "web"
        },
        solutions: []
    };
    fluid.each(solutionIds, function (solutionId) {
        device.solutions.push({ id: solutionId });
    });
    return JSON.stringify(device);
};
 
fluid.defaults("gpii.test.cloudBased.testCaseHolder", {
    gradeNames: ["kettle.test.testCaseHolder"],
    components: {
        fmrequest: {
            type: "kettle.test.request.http",
            options: {
                path: "/%userToken/settings/%device",
                port: 8081,
                termMap: {
                    userToken: "{testCaseHolder}.options.userToken",
                    device: {
                        expander: {
                            func: "gpii.test.cloudBased.computeDevice",
                            args: [["{testCaseHolder}.options.solutionId"], "{testCaseHolder}.options.OSid"]
                        }
                    }
                }
            }
        }
    }
});
 
gpii.test.cloudBased.gpiiConfig = function () {
    return {
        configName: "gpii.tests.acceptance.cloudBased.config.base",
        configPath: "%gpii-universal/tests/platform/cloud/configs"
    };
};
 
gpii.test.cloudBased.buildTestFixture = function (testDef) {
    // Since we modify the testDef object, we make a copy of it to not screw up any other tests that
    // might be sharing the same testDef
    testDef = fluid.copy(testDef);
    testDef.expect = 1;
    testDef.sequence = fluid.makeArray(testDef.sequence);
    testDef.gradeNames = fluid.makeArray(testDef.gradeNames);
    testDef.gradeNames.push("gpii.test.cloudBased.testCaseHolder");
 
    testDef.sequence.unshift({
        func: "{fmrequest}.send"
    }, {
        event: "{fmrequest}.events.onComplete",
        listenerMaker: "gpii.test.cloudBased.FMRequestListenerMaker",
        makerArgs: ["{testCaseHolder}.options.expected"]
    });
    testDef.config = testDef.config || gpii.test.cloudBased.gpiiConfig();
 
    return testDef;
};
 
gpii.test.cloudBased.bootstrap = function (testDefs) {
    return kettle.test.bootstrapServer(testDefs, function (testDef) {
        return gpii.test.cloudBased.buildTestFixture(testDef);
    });
};