-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mocha-start.js
177 lines (154 loc) · 5.11 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
global.Blob = function () {};
global.FileReader = require('filereader');
(function KOMMochaWrap() {
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: 'kommit',
ZDRScopeSchemas: [
require('./os-app/_shared/KOMDeck/main.js').default,
require('./os-app/_shared/KOMCard/main.js').default,
require('./os-app/_shared/KOMSpacing/main.js').default,
require('./os-app/_shared/KOMSetting/main.js').default,
require('./os-app/_shared/KOMTransport/main.js').default,
],
}],
_ZDRParamDispatchJSONPreStringify: require('OLSKObject').OLSKObjectSafeCopy,
});
});
beforeEach(function() {
return ZDRTestingWrap.App.ZDRStorageDeleteFolderRecursive('');
});
})();
(function KOMMochaStubs() {
const KOMSpacing = require('./os-app/_shared/KOMSpacing/main.js').default;
Object.entries({
StubDeckObject(inputData) {
return Object.assign({
KOMDeckName: Math.random().toString(),
}, inputData);
},
StubDeckObjectValid(inputData) {
return Object.assign({
KOMDeckID: Math.random().toString(),
KOMDeckName: Math.random().toString(),
KOMDeckCreationDate: new Date(),
KOMDeckModificationDate: new Date(),
}, inputData);
},
StubCardObject(inputData) {
return Object.assign({
KOMCardFrontText: Math.random().toString(),
KOMCardRearText: Math.random().toString(),
}, inputData);
},
StubCardObjectValid(inputData) {
return Object.assign({
KOMCardID: Math.random().toString(),
KOMCardDeckID: Math.random().toString(),
KOMCardFrontText: Math.random().toString(),
KOMCardRearText: Math.random().toString(),
KOMCardCreationDate: new Date(),
KOMCardModificationDate: new Date(),
}, inputData);
},
StubSpacingObjectValid(inputData, direction, cardID) {
return Object.assign({
KOMSpacingID: (cardID || Math.random().toString()) + '-' + (direction || uRandomElement(KOMSpacing.KOMSpacingLabelBackward(), KOMSpacing.KOMSpacingLabelForward())),
KOMSpacingChronicles: [],
}, inputData);
},
uSpacingUnseen (inputData = {}) {
return StubSpacingObjectValid(Object.assign({
KOMSpacingID: 'bravo-forward',
}, inputData));
},
uSpacingFresh (inputData = {}) {
return uSpacingUnseen(Object.assign({
KOMSpacingIsLearning: true,
KOMSpacingDueDate: new Date(),
}, inputData));
},
StubSpacingObjectHistorical(inputData) {
return StubSpacingObjectValid({
KOMSpacingChronicles: [StubChronicleObjectValid(inputData || new Date(Date.now() - 1000 * 60 * 60 * 24 * 3))],
KOMSpacingDueDate: new Date(),
});
},
StubSpacingArray (inputData = 2) {
return Array.from(new Array(inputData)).map(function (e, i) {
return StubSpacingObjectValid({
KOMSpacingID: (i + 1).toString() + '-' + (i >= 2 ? 'backward' : 'forward'),
KOMSpacingDueDate: i === 1 ? new Date() : undefined,
$KOMSpacingCard: StubCardObjectValid({
KOMCardID: (i + 1).toString(),
KOMCardFrontText: (i + 1).toString(),
}),
});
});
},
StubChronicleObjectValid(inputData = new Date()) {
return {
KOMChronicleDrawDate: new Date(inputData.valueOf() - 10000),
KOMChronicleFlipDate: new Date(inputData.valueOf() - 10000),
KOMChronicleResponseDate: inputData,
KOMChronicleResponseType: 'RESPONSE_EASY',
KOMChronicleDueDate: new Date(inputData.valueOf() + 1000 * 60 * 60 * 24),
};
},
StubChronicleObjectPrepared (inputData = {}) {
return Object.assign({
KOMChronicleDrawDate: new Date('2019-02-23T12:00:00Z'),
KOMChronicleFlipDate: new Date('2019-02-23T12:00:00Z'),
KOMChronicleResponseDate: new Date('2019-02-23T12:00:00Z'),
KOMChronicleResponseType: 'RESPONSE_EASY',
}, inputData);
},
StubChronicleObjectValid2 (inputData = {}) {
return Object.assign(StubChronicleObjectPrepared(), {
KOMChronicleDueDate: new Date('2019-02-23T12:00:00Z'),
}, inputData);
},
StubSettingObjectValid(inputData = {}) {
return Object.assign({
KOMSettingKey: Math.random().toString(),
KOMSettingValue: Math.random().toString(),
}, inputData);
},
StubStateObjectValid(inputData = {}) {
return Object.assign({
KOMPlayStateQueue: [],
KOMPlayStateWait: [],
KOMPlayStateHistory: [],
}, inputData);
},
StubReviewObjectValid(inputData = {}) {
return Object.assign({
KOMReviewScheme: 'kKOMReviewSchemeReviewing',
}, inputData);
},
StubReviewChartElementDateBarTableRowDataObjectValid (inputData) {
return Object.assign({
KOMReviewChartElementDateBarTableRowDataKey: 'alfa',
KOMReviewChartElementDateBarTableRowDataValues: [1, 2, 3],
}, inputData);
},
uSpacings(inputData) {
return StubSpacingArray(inputData).map(function (e, i) {
return Object.assign(e, {
KOMSpacingID: (i + 1).toString() + '-forward',
$KOMSpacingCard: Object.assign(e.$KOMSpacingCard, {
KOMCardNotes: Math.random().toString(),
}),
})
});
},
}).map(function (e) {
return global[e.shift()] = e.pop();
});
})();