orc-scripts 1.2.0-pre.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +19 -0
- package/README.md +76 -0
- package/babel.js +1 -0
- package/eslint.js +1 -0
- package/jest.js +1 -0
- package/package.json +164 -0
- package/prettier.js +1 -0
- package/src/__mocks__/fileMock.js +1 -0
- package/src/config/babel-preset.js +4 -0
- package/src/config/babel-transform.js +4 -0
- package/src/config/babel-whitelist.json +1 -0
- package/src/config/babelrc.js +38 -0
- package/src/config/eslintrc.js +15 -0
- package/src/config/jest-resolver.js +35 -0
- package/src/config/jest.config.js +45 -0
- package/src/config/jestSetupFiles.js +4 -0
- package/src/config/prettier.config.js +9 -0
- package/src/config/setAssetPath.js +1 -0
- package/src/config/unexpected-form.js +317 -0
- package/src/config/unexpected-form.test.js +2397 -0
- package/src/config/unexpected-module.js +112 -0
- package/src/config/unexpected-module.test.js +1106 -0
- package/src/config/unexpected-styles.js +44 -0
- package/src/config/unexpected-styles.test.js +118 -0
- package/src/config/unexpected.js +117 -0
- package/src/config/unexpected.test.js +393 -0
- package/src/config/webpack.config.js +103 -0
- package/src/index.js +19 -0
- package/src/run-script.js +99 -0
- package/src/scripts/build/cli.js +43 -0
- package/src/scripts/build/index.js +9 -0
- package/src/scripts/build/web.js +24 -0
- package/src/scripts/buildDep.js +122 -0
- package/src/scripts/buildIconsSheet.js +50 -0
- package/src/scripts/clean.js +8 -0
- package/src/scripts/extract-messages.js +22 -0
- package/src/scripts/generateApi.js +152 -0
- package/src/scripts/getDist.js +20 -0
- package/src/scripts/mergeTranslations.js +32 -0
- package/src/scripts/prep.js +28 -0
- package/src/scripts/start.js +45 -0
- package/src/scripts/tag.js +76 -0
- package/src/scripts/test.js +26 -0
- package/src/scripts/validateTranslations.js +72 -0
- package/src/utils.js +95 -0
- package/src/utils.test.js +93 -0
- package/webpack.js +1 -0
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
name: "unexpected-form",
|
|
3
|
+
installInto: function (expect) {
|
|
4
|
+
expect.addAssertion("<object> to be a form field", function (expect, subject) {
|
|
5
|
+
const type = subject.type;
|
|
6
|
+
const pattern = {
|
|
7
|
+
type: expect.it("to be a string"),
|
|
8
|
+
name: expect.it("to be a string"),
|
|
9
|
+
};
|
|
10
|
+
switch (type) {
|
|
11
|
+
case "Button":
|
|
12
|
+
addLabelProp(expect, subject, pattern);
|
|
13
|
+
addButtonProps(expect, subject, pattern);
|
|
14
|
+
break;
|
|
15
|
+
case "CheckboxInput":
|
|
16
|
+
addLabelProp(expect, subject, pattern);
|
|
17
|
+
addInputProps(expect, subject, pattern, false);
|
|
18
|
+
break;
|
|
19
|
+
case "DateInput":
|
|
20
|
+
addLabelProp(expect, subject, pattern);
|
|
21
|
+
addInputProps(expect, subject, pattern);
|
|
22
|
+
addDateInputProps(expect, subject, pattern);
|
|
23
|
+
break;
|
|
24
|
+
case "EmailInput":
|
|
25
|
+
addLabelProp(expect, subject, pattern);
|
|
26
|
+
addInputProps(expect, subject, pattern);
|
|
27
|
+
addTextInputProps(expect, subject, pattern);
|
|
28
|
+
addMultipleProp(expect, subject, pattern);
|
|
29
|
+
break;
|
|
30
|
+
case "LineLabel":
|
|
31
|
+
addLabelProp(expect, subject, pattern);
|
|
32
|
+
break;
|
|
33
|
+
case "MultiSelector":
|
|
34
|
+
addLabelProp(expect, subject, pattern);
|
|
35
|
+
addInputProps(expect, subject, pattern);
|
|
36
|
+
addOptionProp(expect, subject, pattern);
|
|
37
|
+
break;
|
|
38
|
+
case "NumberInput":
|
|
39
|
+
addLabelProp(expect, subject, pattern);
|
|
40
|
+
addInputProps(expect, subject, pattern);
|
|
41
|
+
addNumberInputProps(expect, subject, pattern);
|
|
42
|
+
break;
|
|
43
|
+
case "ReadOnly":
|
|
44
|
+
addLabelProp(expect, subject, pattern);
|
|
45
|
+
break;
|
|
46
|
+
case "Selector":
|
|
47
|
+
addLabelProp(expect, subject, pattern);
|
|
48
|
+
addInputProps(expect, subject, pattern);
|
|
49
|
+
addOptionProp(expect, subject, pattern);
|
|
50
|
+
break;
|
|
51
|
+
case "SmallButton":
|
|
52
|
+
addLabelProp(expect, subject, pattern);
|
|
53
|
+
addButtonProps(expect, subject, pattern, true);
|
|
54
|
+
break;
|
|
55
|
+
case "SwitchInput":
|
|
56
|
+
addLabelProp(expect, subject, pattern);
|
|
57
|
+
addInputProps(expect, subject, pattern, false);
|
|
58
|
+
addSwitchInputProps(expect, subject, pattern);
|
|
59
|
+
break;
|
|
60
|
+
case "TextInput":
|
|
61
|
+
addLabelProp(expect, subject, pattern);
|
|
62
|
+
addInputProps(expect, subject, pattern);
|
|
63
|
+
addTextInputProps(expect, subject, pattern);
|
|
64
|
+
break;
|
|
65
|
+
case "TimeInput":
|
|
66
|
+
addLabelProp(expect, subject, pattern);
|
|
67
|
+
addInputProps(expect, subject, pattern);
|
|
68
|
+
addTimeInputProps(expect, subject, pattern);
|
|
69
|
+
break;
|
|
70
|
+
case "TranslationInput":
|
|
71
|
+
pattern.moreLabel = expect.it("to be a label");
|
|
72
|
+
addLabelProp(expect, subject, pattern);
|
|
73
|
+
addInputProps(expect, subject, pattern);
|
|
74
|
+
addTextInputProps(expect, subject, pattern);
|
|
75
|
+
break;
|
|
76
|
+
default:
|
|
77
|
+
if (["Fieldset", "Combination", "List"].includes(type)) {
|
|
78
|
+
return expect.fail();
|
|
79
|
+
}
|
|
80
|
+
expect.errorMode = "nested";
|
|
81
|
+
return expect.fail("Invalid type {0}", type);
|
|
82
|
+
}
|
|
83
|
+
return expect(subject, "to satisfy", pattern);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
expect.addAssertion("<object> to be a form combination field", function (expect, subject) {
|
|
87
|
+
if (subject.type !== "Combination") {
|
|
88
|
+
expect.fail();
|
|
89
|
+
}
|
|
90
|
+
const pattern = {
|
|
91
|
+
type: "Combination",
|
|
92
|
+
fields: expect.it("to be an array").and("to have items satisfying", "to be a form field"),
|
|
93
|
+
};
|
|
94
|
+
if (subject.hasOwnProperty("proportions")) {
|
|
95
|
+
pattern.proportions = expect
|
|
96
|
+
.it("to be an array")
|
|
97
|
+
.and("to have items satisfying", expect.it("to be a string").or("to be a number"))
|
|
98
|
+
.and("to be shorter than or same length as", subject.fields);
|
|
99
|
+
}
|
|
100
|
+
return expect(subject, "to satisfy", pattern);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
expect.addAssertion("<object> to be a form list", function (expect, subject) {
|
|
104
|
+
if (subject.type !== "List") {
|
|
105
|
+
expect.fail();
|
|
106
|
+
}
|
|
107
|
+
const pattern = {
|
|
108
|
+
type: "List",
|
|
109
|
+
name: expect.it("to be a string"),
|
|
110
|
+
rowField: expect.it("to be a form field").or("to be a form combination field"),
|
|
111
|
+
};
|
|
112
|
+
if (subject.hasOwnProperty("rowCount")) {
|
|
113
|
+
pattern.rowCount = expect.it("to be a number");
|
|
114
|
+
}
|
|
115
|
+
if (subject.hasOwnProperty("add")) {
|
|
116
|
+
if (subject.rowCount) {
|
|
117
|
+
expect.errorMode = "nested";
|
|
118
|
+
return expect.fail("Form list with row count cannot have 'add' label");
|
|
119
|
+
}
|
|
120
|
+
pattern.add = expect.it("to be a label");
|
|
121
|
+
}
|
|
122
|
+
if (subject.hasOwnProperty("staticValues")) {
|
|
123
|
+
if (!subject.rowCount) {
|
|
124
|
+
expect.errorMode = "nested";
|
|
125
|
+
return expect.fail("Form list without row count cannot have static values");
|
|
126
|
+
}
|
|
127
|
+
pattern.staticValues = expect.it("to be an array");
|
|
128
|
+
}
|
|
129
|
+
return expect(subject, "to satisfy", pattern);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
expect.addAssertion("<object> to be a form fieldset", function (expect, subject) {
|
|
133
|
+
if (subject.type !== "Fieldset") {
|
|
134
|
+
expect.fail();
|
|
135
|
+
}
|
|
136
|
+
const pattern = {
|
|
137
|
+
type: "Fieldset",
|
|
138
|
+
label: expect.it("to be a label"),
|
|
139
|
+
fields: expect
|
|
140
|
+
.it("to be an array")
|
|
141
|
+
.and(
|
|
142
|
+
"to have items satisfying",
|
|
143
|
+
expect.it("to be a form field").or("to be a form combination field").or("to be a form list"),
|
|
144
|
+
),
|
|
145
|
+
};
|
|
146
|
+
expect(subject, "to satisfy", pattern);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
expect.addAssertion("<array-like> to be a form definition", function (expect, subject) {
|
|
150
|
+
return expect(
|
|
151
|
+
subject,
|
|
152
|
+
"to have items satisfying",
|
|
153
|
+
expect
|
|
154
|
+
.it("to be a form field")
|
|
155
|
+
.or("to be a form combination field")
|
|
156
|
+
.or("to be a form list")
|
|
157
|
+
.or("to be a form fieldset"),
|
|
158
|
+
);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
expect.addAssertion(
|
|
162
|
+
[
|
|
163
|
+
"<undefined> to be a form field",
|
|
164
|
+
"<undefined> to be a form combination field",
|
|
165
|
+
"<undefined> to be a form list",
|
|
166
|
+
"<undefined> to be a form fieldset",
|
|
167
|
+
],
|
|
168
|
+
function (expect) {
|
|
169
|
+
return expect.fail();
|
|
170
|
+
},
|
|
171
|
+
);
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const addLabelProp = (expect, subject, pattern) => {
|
|
176
|
+
if (subject.hasOwnProperty("label")) {
|
|
177
|
+
pattern.label = expect.it("to be a label");
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const addMultipleProp = (expect, subject, pattern) => {
|
|
182
|
+
if (subject.hasOwnProperty("multiple")) {
|
|
183
|
+
pattern.multiple = expect.it("to be a boolean");
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const addButtonProps = (expect, subject, pattern, small) => {
|
|
188
|
+
if (subject.hasOwnProperty("primary")) {
|
|
189
|
+
pattern.primary = expect.it("to be a boolean");
|
|
190
|
+
}
|
|
191
|
+
if (subject.hasOwnProperty("active")) {
|
|
192
|
+
pattern.active = expect.it("to be a boolean");
|
|
193
|
+
}
|
|
194
|
+
if (small) {
|
|
195
|
+
pattern.altText = expect.it("to be a label");
|
|
196
|
+
pattern.icon = expect.it("to be a string");
|
|
197
|
+
} else {
|
|
198
|
+
if (subject.hasOwnProperty("buttonText")) {
|
|
199
|
+
pattern.buttonText = expect.it("to be a label");
|
|
200
|
+
}
|
|
201
|
+
if (subject.hasOwnProperty("icon")) {
|
|
202
|
+
pattern.icon = expect.it("to be a string");
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (subject.hasOwnProperty("autofocus")) {
|
|
206
|
+
pattern.autofocus = expect.it("to be a boolean");
|
|
207
|
+
}
|
|
208
|
+
if (subject.hasOwnProperty("disabled")) {
|
|
209
|
+
pattern.disabled = expect.it("to be a boolean");
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
const addInputProps = (expect, subject, pattern, textual = true) => {
|
|
214
|
+
if (textual && subject.hasOwnProperty("autocomplete")) {
|
|
215
|
+
pattern.autocomplete = expect.it("to be a string");
|
|
216
|
+
}
|
|
217
|
+
if (subject.hasOwnProperty("autofocus")) {
|
|
218
|
+
pattern.autofocus = expect.it("to be a boolean");
|
|
219
|
+
}
|
|
220
|
+
if (subject.hasOwnProperty("disabled")) {
|
|
221
|
+
pattern.disabled = expect.it("to be a boolean");
|
|
222
|
+
}
|
|
223
|
+
if (textual && subject.hasOwnProperty("readOnly")) {
|
|
224
|
+
pattern.readOnly = expect.it("to be a boolean");
|
|
225
|
+
}
|
|
226
|
+
if (subject.hasOwnProperty("required")) {
|
|
227
|
+
pattern.required = expect.it("to be a label");
|
|
228
|
+
}
|
|
229
|
+
if (subject.hasOwnProperty("tabindex")) {
|
|
230
|
+
pattern.tabindex = expect.it("to be a number");
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
const addTextInputProps = (expect, subject, pattern) => {
|
|
235
|
+
if (subject.hasOwnProperty("maxlength")) {
|
|
236
|
+
pattern.maxlength = expect.it("to be a number").and("to be greater than", 0);
|
|
237
|
+
}
|
|
238
|
+
if (subject.hasOwnProperty("minlength")) {
|
|
239
|
+
pattern.minlength = expect.it("to be a number").and("to be greater than", 0);
|
|
240
|
+
}
|
|
241
|
+
if (subject.hasOwnProperty("pattern")) {
|
|
242
|
+
pattern.pattern = expect.it("to be a regular expression");
|
|
243
|
+
}
|
|
244
|
+
if (subject.hasOwnProperty("placeholder")) {
|
|
245
|
+
pattern.placeholder = expect.it("to be a label");
|
|
246
|
+
}
|
|
247
|
+
if (subject.hasOwnProperty("size")) {
|
|
248
|
+
pattern.size = expect.it("to be a number").and("to be greater than", 0);
|
|
249
|
+
}
|
|
250
|
+
if (subject.hasOwnProperty("spellcheck")) {
|
|
251
|
+
pattern.spellcheck = expect.it("to be a boolean").or("to be", "");
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
const addNumberInputProps = (expect, subject, pattern) => {
|
|
256
|
+
if (subject.hasOwnProperty("max")) {
|
|
257
|
+
pattern.max = expect.it("to be a number");
|
|
258
|
+
}
|
|
259
|
+
if (subject.hasOwnProperty("min")) {
|
|
260
|
+
pattern.min = expect.it("to be a number");
|
|
261
|
+
}
|
|
262
|
+
if (subject.hasOwnProperty("step")) {
|
|
263
|
+
pattern.step = expect.it("to be a number");
|
|
264
|
+
}
|
|
265
|
+
if (subject.hasOwnProperty("placeholder")) {
|
|
266
|
+
pattern.placeholder = expect.it("to be a label");
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
const addDateInputProps = (expect, subject, pattern) => {
|
|
271
|
+
if (subject.hasOwnProperty("max")) {
|
|
272
|
+
pattern.max = expect.it("to be a string").and("to match", /^\d{4}-\d{2}-\d{2}$/);
|
|
273
|
+
}
|
|
274
|
+
if (subject.hasOwnProperty("min")) {
|
|
275
|
+
pattern.min = expect.it("to be a string").and("to match", /^\d{4}-\d{2}-\d{2}$/);
|
|
276
|
+
}
|
|
277
|
+
if (subject.hasOwnProperty("step")) {
|
|
278
|
+
pattern.step = expect.it("to be a number");
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
const addTimeInputProps = (expect, subject, pattern) => {
|
|
283
|
+
if (subject.hasOwnProperty("max")) {
|
|
284
|
+
pattern.max = expect.it("to be a string").and("to match", /^\d{2}:\d{2}(?::\d{2})?$/);
|
|
285
|
+
}
|
|
286
|
+
if (subject.hasOwnProperty("min")) {
|
|
287
|
+
pattern.min = expect.it("to be a string").and("to match", /^\d{2}:\d{2}(?::\d{2})?$/);
|
|
288
|
+
}
|
|
289
|
+
if (subject.hasOwnProperty("step")) {
|
|
290
|
+
pattern.step = expect.it("to be a number").or("to be", "any");
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
const addSwitchInputProps = (expect, subject, pattern) => {
|
|
295
|
+
if (subject.hasOwnProperty("onCaption")) {
|
|
296
|
+
pattern.onCaption = expect.it("to be a label");
|
|
297
|
+
}
|
|
298
|
+
if (subject.hasOwnProperty("offCaption")) {
|
|
299
|
+
pattern.offCaption = expect.it("to be a label");
|
|
300
|
+
}
|
|
301
|
+
if (subject.hasOwnProperty("onColor")) {
|
|
302
|
+
pattern.onColor = expect.it("to be a string");
|
|
303
|
+
}
|
|
304
|
+
if (subject.hasOwnProperty("offColor")) {
|
|
305
|
+
pattern.offColor = expect.it("to be a string");
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
const addOptionProp = (expect, subject, pattern) => {
|
|
310
|
+
pattern.options = expect
|
|
311
|
+
.it("to be an array")
|
|
312
|
+
.and("to have items satisfying", {
|
|
313
|
+
label: expect.it("to be a label"),
|
|
314
|
+
value: expect.it("to be defined"),
|
|
315
|
+
})
|
|
316
|
+
.or("to equal", []);
|
|
317
|
+
};
|