-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmocha-start.js
94 lines (84 loc) · 2.51 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
(function LCHMochaWrap() {
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: 'launchlet',
ZDRScopeSchemas: [
require('./os-app/_shared/LCHDocument/main.js').default,
require('./os-app/_shared/LCHSetting/main.js').default,
require('./os-app/_shared/LCHTransport/main.js').default,
],
}],
});
});
beforeEach(function() {
return ZDRTestingWrap.App.ZDRStorageDeleteFolderRecursive('');
});
})();
(function LCHMochaStubs() {
Object.entries({
uStubDocument (inputData = {}) {
return Object.assign({
LCHDocumentCallbackArgs: Math.random().toString(),
LCHDocumentCallbackBody: Math.random().toString(),
}, inputData);
},
StubDocumentObjectValid (inputData = {}) {
return Object.assign(uStubDocument({
LCHDocumentID: Math.random().toString(),
LCHDocumentCreationDate: new Date(),
LCHDocumentModificationDate: new Date(),
}), inputData);
},
StubSettingObjectValid (inputData = {}) {
return Object.assign({
LCHSettingKey: Math.random().toString(),
LCHSettingValue: Math.random().toString(),
}, inputData);
},
uStubTwoItems () {
return [
{
LCHRecipeName: 'alfa',
LCHRecipeCallback: function () {
return document.getElementById('TestRecipeOutput').value = 'alfa';
},
},
{
LCHRecipeName: 'bravo',
LCHRecipeCallback: function () {
return document.getElementById('TestRecipeOutput').value = 'bravo';
},
},
];
},
uStubStringify (inputData) {
return JSON.stringify(inputData.map(function (e) {
return Object.assign(e, {
LCHRecipeCallback: `(${ e.LCHRecipeCallback.toString() })`,
LCHRecipeIsExcluded: e.LCHRecipeIsExcluded ? `(${ e.LCHRecipeIsExcluded.toString() })` : undefined,
});
})).replace('#', encodeURIComponent('#'));
},
uStubStringifyAll (inputData) {
return JSON.stringify(Object.fromEntries(Object.entries(inputData).map(function (e) {
if (e[0] === 'LCHOptionRecipes') {
e[1] = e[1].map(function (e) {
return Object.assign(e, {
LCHRecipeCallback: `(${ e.LCHRecipeCallback.toString() })`,
LCHRecipeIsExcluded: e.LCHRecipeIsExcluded ? `(${ e.LCHRecipeIsExcluded.toString() })` : undefined,
});
});
};
return e;
})));
},
}).map(function (e) {
return global[e.shift()] = e.pop();
});
})();