-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmocha-start.js
80 lines (70 loc) · 2 KB
/
mocha-start.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
(function KVCMochaWrap() {
if (process.env.OLSK_SPEC_MOCHA_INTERFACE === 'true') {
return;
}
before(async function() {
global.ZDRTestingWrap = await require('zerodatawrap').ZDRWrap({
ZDRParamLibrary: require('remotestoragejs'),
ZDRParamScopes: [{
ZDRScopeKey: 'App',
ZDRScopeDirectory: 'wikiavec',
ZDRScopeSchemas: [
require('./os-app/_shared/KVCNote/main.js').default,
require('./os-app/_shared/KVCSetting/main.js').default,
require('./os-app/_shared/KVCTransport/main.js').default,
],
}, {
ZDRScopeKey: 'Public',
ZDRScopeDirectory: 'wikiavec',
ZDRScopeIsPublic: true,
}],
});
});
beforeEach(function() {
return ZDRTestingWrap.App.ZDRStorageDeleteFolderRecursive('');
});
beforeEach(function() {
return ZDRTestingWrap.Public.ZDRStorageDeleteFolderRecursive('');
});
})();
(function KVCMochaStubs() {
Object.entries({
StubNoteObject(inputData) {
return Object.assign({
KVCNoteBody: Math.random().toString(),
}, inputData);
},
StubNoteObjectValid(inputData) {
return Object.assign({
KVCNoteID: Math.random().toString(),
KVCNoteBody: Math.random().toString(),
KVCNoteCreationDate: new Date(),
KVCNoteModificationDate: new Date(),
}, inputData);
},
StubNoteObjectPublic(inputData = {}) {
return Object.assign(StubNoteObjectValid({
KVCNoteIsPublic: true,
KVCNotePublishDate: new Date(),
KVCNotePublicID: Math.random().toString(),
}), inputData);
},
StubSettingObjectValid (inputData = {}) {
return Object.assign({
KVCSettingKey: Math.random().toString(),
KVCSettingValue: Math.random().toString(),
}, inputData);
},
uSerial (inputData) {
return inputData.reduce(async function (coll, e) {
return e.then(Array.prototype.concat.bind(await coll));
}, Promise.resolve([]));
},
uSleep (inputData) {
let endTime = new Date().getTime();
while (new Date().getTime() < endTime + inputData) {}
},
}).map(function (e) {
return global[e.shift()] = e.pop();
});
})();