-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobals.js
57 lines (50 loc) · 1.62 KB
/
globals.js
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
// This is used by the test/plugins tests
/*globals requireJS*/
/*jshint node:true*/
/**
* @author pmeijer / https://github.com/pmeijer
*/
var testFixture = require('webgme/test/_globals'),
WEBGME_CONFIG_PATH = '../config';
// This flag will make sure the config.test.js is being used
// process.env.NODE_ENV = 'test'; // This is set by the require above, overwrite it here.
var WebGME = testFixture.WebGME,
gmeConfig = require(WEBGME_CONFIG_PATH),
getGmeConfig = function () {
'use strict';
// makes sure that for each request it returns with a unique object and tests will not interfere
if (!gmeConfig) {
// if some tests are deleting or unloading the config
gmeConfig = require(WEBGME_CONFIG_PATH);
}
return JSON.parse(JSON.stringify(gmeConfig));
};
WebGME.addToRequireJsPaths(gmeConfig);
testFixture.getGmeConfig = getGmeConfig;
testFixture.clearDbImportProject = function (obj) {
var deferred = testFixture.Q.defer();
var gmeAuth, storage;
testFixture.clearDBAndGetGMEAuth(gmeConfig, null)
.then(function (gmeAuth_) {
gmeAuth = gmeAuth_;
storage = testFixture.getMemoryStorage(obj.logger, gmeConfig, gmeAuth_);
return storage.openDatabase();
})
.then(function () {
return testFixture.importProject(storage, {
projectSeed: obj.seed,
projectName: obj.projectName,
gmeConfig: gmeConfig,
logger: obj.logger
});
})
.then(function (result) {
deferred.resolve({
gmeAuth: gmeAuth,
storage: storage,
result: result
});
});
return deferred.promise;
};
module.exports = testFixture;