-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mocha-start.js
102 lines (87 loc) · 3.47 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
const SNPDocument = require('./os-app/_shared/SNPDocument/main.js').default;
(function SNPMochaWrap() {
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: 'sharesnip',
ZDRScopeSchemas: [
SNPDocument,
require('./os-app/_shared/SNPSetting/main.js').default,
require('./os-app/_shared/SNPTransport/main.js').default,
],
}],
_ZDRParamDispatchJSONPreStringify: require('OLSKObject').OLSKObjectSafeCopy,
});
});
beforeEach(function() {
return ZDRTestingWrap.App.ZDRStorageDeleteFolderRecursive('');
});
})();
(function SNPMochaStubs() {
Object.entries({
StubDocumentObject(inputData) {
return Object.assign({
SNPDocumentData: Math.random().toString(),
SNPDocumentName: '',
SNPDocumentType: SNPDocument.SNPDocumentTypeNote(),
}, inputData);
},
StubDocumentObjectValid(inputData) {
return StubDocumentObject(Object.assign({
SNPDocumentID: Math.random().toString(),
SNPDocumentCreationDate: new Date(),
SNPDocumentModificationDate: new Date(),
}, inputData));
},
StubSettingObjectValid (inputData = {}) {
return Object.assign({
SNPSettingKey: Math.random().toString(),
SNPSettingValue: Math.random().toString(),
}, inputData);
},
async uCreateDocument () {
await browser.pressButton('.SNPCollectToggleFormButton');
await browser.pressButton('.SNPMakeTypesNoteButton');
await browser.fill('.SNPFormDataField', Math.random().toString());
return browser.pressButton('.SNPFormBaseSaveButton');
},
uDataSite (inputData = '') {
return uRandomElement('http', 'https') + '://example.com/' + (inputData || Math.random().toString());
},
uDataEmail (inputData) {
return 'mailto:' + uEmail(inputData);
},
uDataPhone (inputData) {
return 'tel:' + (inputData || Math.random().toString());
},
uDataWifi (inputData = '') {
return `WIFI:T:${ inputData.SNPDocumentWifiSecurity || 'WPA' };S:${ inputData.SNPDocumentWifiNetwork || inputData || Math.random().toString() };P:${ inputData.SNPDocumentWifiPassword || inputData || Math.random().toString() };H:${ inputData.SNPDocumentWifiHidden || '' };;`
},
uDataContact (inputData = {}) {
Object.assign(inputData, {
SNPDocumentContactFirstName: inputData.SNPDocumentContactFirstName || Math.random().toString(),
SNPDocumentContactLastName: inputData.SNPDocumentContactLastName || Math.random().toString(),
SNPDocumentContactOrganization: inputData.SNPDocumentContactOrganization || Math.random().toString(),
SNPDocumentContactPhone: inputData.SNPDocumentContactPhone || Math.random().toString(),
SNPDocumentContactEmail: inputData.SNPDocumentContactEmail || Math.random().toString(),
SNPDocumentContactSite: inputData.SNPDocumentContactSite || Math.random().toString(),
});
return `BEGIN:VCARD
VERSION:3.0
N:${ inputData.SNPDocumentContactLastName };${ inputData.SNPDocumentContactFirstName }
FN:${ inputData.SNPDocumentContactFirstName } ${ inputData.SNPDocumentContactLastName }
ORG:${ inputData.SNPDocumentContactOrganization }
EMAIL;type=INTERNET;type=HOME;type=pref:${ inputData.SNPDocumentContactEmail }
TEL;type=CELL;type=VOICE;type=pref:${ inputData.SNPDocumentContactPhone }
URL:${ inputData.SNPDocumentContactSite }
END:VCARD`
},
}).map(function (e) {
return global[e.shift()] = e.pop();
});
})();