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

100% Statements 10/10
100% Branches 0/0
100% Functions 1/1
100% Lines 10/10

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                            1x 1x   1x 1x   1x                                                                                                             1x                   1x                   1x 29x 29x    
/*!
GPII PouchDB testing support
 
Copyright 2016 OCAD University
 
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/LICENSE.txt
*/
 
"use strict";
 
var fluid = require("infusion"),
    gpii = fluid.registerNamespace("gpii");
 
require("gpii-pouchdb");
gpii.pouch.loadTestingSupport();
 
fluid.defaults("gpii.test.pouch.pouchTestCaseHolder", {
    gradeNames: ["fluid.component"],
    distributeOptions: [
        {
            source: "{that}.options.pouchConfig",
            target: "{that gpii.pouch.express}.options"
        },
        {
            record: {
                "{testCaseHolder}.events.onCleanup": "{that}.events.onCleanup.fire"
            },
            target: "{that gpii.pouch.express}.options.listeners"
        },
        {
            record: {
                "onCleanupComplete.escalate": "{testCaseHolder}.events.onCleanupComplete.fire"
            },
            target: "{that gpii.pouch.express}.options.listeners"
        }
    ],
    pouchConfig: {
        databases: {
            auth: {
                data: [
                    "%gpii-universal/tests/platform/cloud/OAuth2AcceptanceDataStore.json",
                    "%gpii-oauth2/gpii-oauth2-datastore/dbViews/views.json"
                ]
            }
        }
    },
    events: {
        constructFixtures: null,
        onPouchHarnessReady: null,
        onFixturesConstructed: {
            events: {
                onPouchHarnessReady: "onPouchHarnessReady"
            }
        },
        onCleanup: null,
        onCleanupComplete: null
    },
    components: {
        pouchHarness: {
            type: "gpii.pouch.harness",
            createOnEvent: "constructFixtures",
            options: {
                port: 8058, // TODO: Use gpii-pouch port from configuration
                listeners: {
                    "onReady.escalate": "{testCaseHolder}.events.onPouchHarnessReady.fire"
                }
            }
        }
    }
});
 
gpii.test.pouch.constructFixturesSequence = [
    {
        func: "{testCaseHolder}.events.constructFixtures.fire"
    },
    {
        event: "{testCaseHolder}.events.onFixturesConstructed",
        listener: "fluid.identity"
    }
];
 
gpii.test.pouch.cleanUpDB = [
    {
        func: "{testCaseHolder}.events.onCleanup.fire"
    },
    {
        event: "{testCaseHolder}.events.onCleanupComplete",
        listener: "fluid.identity"
    }
];
 
gpii.test.pouch.addConstructFixturesToSequence = function (sequence) {
    sequence.unshift.apply(sequence, gpii.test.pouch.constructFixturesSequence);
    return sequence.concat(gpii.test.pouch.cleanUpDB);
};