/*!
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);
};
|