All files / universal/gpii/node_modules/gpii-oauth2/gpii-oauth2-datastore/test/js DataSource-PouchDBTestsUtils.js

100% Statements 4/4
50% Branches 1/2
100% Functions 1/1
100% Lines 4/4

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                          6x   6x       6x                                                                                           6x                                              
/*!
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/blob/master/LICENSE.txt
*/
 
/* eslint-env browser */
/* eslint strict: ["error", "function"] */
 
var fluid = fluid || require("infusion");
 
(function () {
 
    "use strict";
 
    fluid.defaults("gpii.tests.inBrowserPouchDB.testEnvironment", {
        gradeNames: ["fluid.test.testEnvironment"],
        pouchData: [],   // Configurable by integrators
        dbName: "auth",    // Configurable by integrators
        components: {
            pouchDb: {
                type: "gpii.pouch",
                createOnEvent: "constructFixtures",
                options: {
                    dbOptions: {
                        name: "{gpii.tests.inBrowserPouchDB.testEnvironment}.options.dbName"
                    },
                    data: "{gpii.tests.inBrowserPouchDB.testEnvironment}.options.pouchData",
                    listeners: {
                        "onCreate.populateData": {
                            listener: "{that}.bulkDocs",
                            args: ["{that}.options.data"]
                        },
                        "onBulkDocsComplete.escalate": "{gpii.tests.inBrowserPouchDB.testEnvironment}.events.onPouchReady"
                    }
                }
            }
        },
        mergePolicy: {
            rawModules: "noexpand"
        },
        distributeOptions: {
            "rawModules": {
                source: "{that}.options.rawModules",
                target: "{that > testCaseHolder}.options.rawModules"
            }
        },
        events: {
            constructFixtures: null,
            onPouchReady: null,
            onFixturesConstructed: {
                events: {
                    onPouchReady: "onPouchReady"
                }
            }
        }
    });
 
    // The base grade for the test case holder that starts tests when the testing fixtures are ready
    // and also destroy the pouchDB after each test sequence so the next test sequence can start with
    // a fresh data set.
    fluid.defaults("gpii.tests.inBrowserPouchDB.baseTestCaseHolder", {
        gradeNames: ["gpii.test.express.caseHolder.base"],
        sequenceStart: [{
            func: "{gpii.tests.inBrowserPouchDB.testEnvironment}.events.constructFixtures.fire"
        }, {
            event: "{gpii.tests.inBrowserPouchDB.testEnvironment}.events.onFixturesConstructed",
            listener: "fluid.log",
            args: ["PouchDB is ready"]
        }],
        sequenceEnd: [{
            func: "{gpii.tests.inBrowserPouchDB.testEnvironment}.pouchDb.destroyPouch"
        }, {
            event:    "{gpii.tests.inBrowserPouchDB.testEnvironment}.pouchDb.events.onPouchDestroyComplete",
            listener: "fluid.log",
            args:     ["PouchDB cleanup complete"]
        }],
        events: {
            onResponse: null,
            onError: null
        }
    });
 
})();