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.
Files changed (47) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +76 -0
  3. package/babel.js +1 -0
  4. package/eslint.js +1 -0
  5. package/jest.js +1 -0
  6. package/package.json +164 -0
  7. package/prettier.js +1 -0
  8. package/src/__mocks__/fileMock.js +1 -0
  9. package/src/config/babel-preset.js +4 -0
  10. package/src/config/babel-transform.js +4 -0
  11. package/src/config/babel-whitelist.json +1 -0
  12. package/src/config/babelrc.js +38 -0
  13. package/src/config/eslintrc.js +15 -0
  14. package/src/config/jest-resolver.js +35 -0
  15. package/src/config/jest.config.js +45 -0
  16. package/src/config/jestSetupFiles.js +4 -0
  17. package/src/config/prettier.config.js +9 -0
  18. package/src/config/setAssetPath.js +1 -0
  19. package/src/config/unexpected-form.js +317 -0
  20. package/src/config/unexpected-form.test.js +2397 -0
  21. package/src/config/unexpected-module.js +112 -0
  22. package/src/config/unexpected-module.test.js +1106 -0
  23. package/src/config/unexpected-styles.js +44 -0
  24. package/src/config/unexpected-styles.test.js +118 -0
  25. package/src/config/unexpected.js +117 -0
  26. package/src/config/unexpected.test.js +393 -0
  27. package/src/config/webpack.config.js +103 -0
  28. package/src/index.js +19 -0
  29. package/src/run-script.js +99 -0
  30. package/src/scripts/build/cli.js +43 -0
  31. package/src/scripts/build/index.js +9 -0
  32. package/src/scripts/build/web.js +24 -0
  33. package/src/scripts/buildDep.js +122 -0
  34. package/src/scripts/buildIconsSheet.js +50 -0
  35. package/src/scripts/clean.js +8 -0
  36. package/src/scripts/extract-messages.js +22 -0
  37. package/src/scripts/generateApi.js +152 -0
  38. package/src/scripts/getDist.js +20 -0
  39. package/src/scripts/mergeTranslations.js +32 -0
  40. package/src/scripts/prep.js +28 -0
  41. package/src/scripts/start.js +45 -0
  42. package/src/scripts/tag.js +76 -0
  43. package/src/scripts/test.js +26 -0
  44. package/src/scripts/validateTranslations.js +72 -0
  45. package/src/utils.js +95 -0
  46. package/src/utils.test.js +93 -0
  47. package/webpack.js +1 -0
@@ -0,0 +1,44 @@
1
+ // const ReactTestUtils = require("react-dom/test-utils");
2
+
3
+ module.exports = {
4
+ name: "unexpected-styles",
5
+ version: "0.0.2",
6
+ dependencies: ["unexpected-reaction", "unexpected-dom"],
7
+ installInto: function (expect) {
8
+ const getStyleDeclarations = selector => {
9
+ const sheets = document.querySelectorAll("style");
10
+ let declarations = "";
11
+ for (let j = 0; j < sheets.length; j += 1) {
12
+ const sheet = sheets[j].sheet;
13
+ for (let i = 0; i < sheet.cssRules.length; i += 1) {
14
+ const ruleSelector = sheet.cssRules[i].selectorText || "";
15
+ if (ruleSelector.indexOf(selector) !== -1) {
16
+ declarations += sheet.cssRules[i].cssText;
17
+ }
18
+ }
19
+ }
20
+ return declarations;
21
+ };
22
+
23
+ expect.addAssertion("<string> as a selector to have style rules <assertion?>", function (expect, selector) {
24
+ return expect.shift(getStyleDeclarations(selector));
25
+ });
26
+
27
+ expect.addAssertion(
28
+ "<DOMElement> to have style rules satisfying <assertion>",
29
+ function (expect, element, ...assertion) {
30
+ expect.errorMode = "nested";
31
+ const classes = element.getAttribute("class");
32
+ if (!classes) {
33
+ return expect.fail("{0} has no class name", element);
34
+ }
35
+ const styleRules = classes
36
+ .split(" ")
37
+ .map(sel => getStyleDeclarations("." + sel))
38
+ .filter(Boolean)
39
+ .join("\n");
40
+ return expect.shift(styleRules);
41
+ },
42
+ );
43
+ },
44
+ };
@@ -0,0 +1,118 @@
1
+ import React from "react";
2
+ import styled from "styled-components";
3
+
4
+ const TestStyled = styled.div`
5
+ color: red;
6
+ background-color: green;
7
+ `;
8
+
9
+ const SvgStyled = styled.svg`
10
+ height: 10px;
11
+ width: 100px;
12
+ `;
13
+
14
+ describe("Styled component plugin for unexpected", () => {
15
+ let firstSheet, secondSheet;
16
+ beforeEach(() => {
17
+ firstSheet = document.createElement("style");
18
+ firstSheet.appendChild(document.createTextNode(""));
19
+ document.head.appendChild(firstSheet);
20
+ const sheet = firstSheet.sheet;
21
+ sheet.insertRule("html { margin: 0; }", 0);
22
+ sheet.insertRule("body { padding: 0; }", 1);
23
+ sheet.insertRule(".foo { color: green; }", 2);
24
+ secondSheet = document.createElement("style");
25
+ secondSheet.appendChild(document.createTextNode(""));
26
+ document.head.appendChild(secondSheet);
27
+ secondSheet.sheet.insertRule(".bar { color: blue; }", 0);
28
+ });
29
+ afterEach(() => {
30
+ document.head.removeChild(firstSheet);
31
+ document.head.removeChild(secondSheet);
32
+ });
33
+
34
+ describe("<string> as a selector to have style rules <assertion?>", () => {
35
+ it("passes when a style matches", () => expect(".foo", "as a selector to have style rules", "to contain", "green"));
36
+
37
+ it("works with html tag", () => expect("html", "as a selector to have style rules", "to contain", "margin"));
38
+
39
+ it("works with body tag", () => expect("body", "as a selector to have style rules", "to contain", "padding"));
40
+
41
+ it("works on a second style sheet", () =>
42
+ expect(".bar", "as a selector to have style rules", "to contain", "color: blue;"));
43
+
44
+ it("gives a decent diff", () =>
45
+ expect(
46
+ () => expect(".foo", "as a selector to have style rules", "to contain", "width"),
47
+ "to throw",
48
+ "expected '.foo' as a selector to have style rules to contain 'width'\n\n.foo {color: green;}",
49
+ ));
50
+ });
51
+
52
+ describe("<DOMElement> to have style rules satisfying <assertion>", () => {
53
+ it("passes with DOM element", () =>
54
+ expect(
55
+ <div className="ban foo boof" />,
56
+ "when mounted",
57
+ "to have style rules satisfying",
58
+ "to contain",
59
+ "color: green;",
60
+ ));
61
+
62
+ it("passes with DOM element referencing second style sheet", () =>
63
+ expect(
64
+ <div className="ban bar boof" />,
65
+ "when mounted",
66
+ "to have style rules satisfying",
67
+ "to contain",
68
+ "color: blue;",
69
+ ));
70
+
71
+ it("passes with SVG element", () =>
72
+ expect(
73
+ <SvgStyled />,
74
+ "when mounted",
75
+ "to have style rules satisfying",
76
+ expect.it("to be a", "string").and("to contain", "width: 100px;"),
77
+ ));
78
+
79
+ it("passes with a styled component", () =>
80
+ expect(
81
+ <TestStyled />,
82
+ "when mounted",
83
+ "to have style rules satisfying",
84
+ expect.it("to be a", "string").and("to contain", "color: red;"),
85
+ ));
86
+
87
+ it("gives a detailed diff", () =>
88
+ expect(
89
+ () => expect(<TestStyled />, "when mounted", "to have style rules satisfying", "to contain", "color: blue;"),
90
+ "to throw",
91
+ new RegExp(
92
+ 'expected <div class="unexpected-stylestest__TestStyled-sc-\\w+-0 [\\w-]+"></div>\n' +
93
+ "to have style rules satisfying to contain 'color: blue;'\n" +
94
+ " expected '\\.\\w+ \\{color: red; background-color: green;\\}' to contain 'color: blue;'\n" +
95
+ "\n" +
96
+ " \\.\\w+ \\{color: red; background-color: green;\\}\n" +
97
+ " \\^\\^\\^\\^\\^\\^\\^ \\^\\^\\^\\^\\^\\^\\^",
98
+ ),
99
+ ));
100
+
101
+ it("fails if no class name", () =>
102
+ expect(
103
+ () => expect(<div id="foo" />, "when mounted", "to have style rules satisfying", "to be ok"),
104
+ "to throw",
105
+ 'expected <div id="foo"></div> to have style rules satisfying to be ok\n' +
106
+ ' <div id="foo"></div> has no class name',
107
+ ));
108
+
109
+ it("fails if empty class name", () =>
110
+ expect(
111
+ () => expect(<div id="foo" className="" />, "when mounted", "to have style rules satisfying", "to be a string"),
112
+ "to throw",
113
+ 'expected <div id="foo" class=""></div>\n' +
114
+ "to have style rules satisfying to be a string\n" +
115
+ ' <div id="foo" class=""></div> has no class name',
116
+ ));
117
+ });
118
+ });
@@ -0,0 +1,117 @@
1
+ const unexpected = require("unexpected");
2
+ const unexpectedDom = require("unexpected-dom");
3
+ const unexpectedReaction = require("unexpected-reaction");
4
+ const unexpectedSinon = require("unexpected-sinon");
5
+ const unexpectedImmutable = require("unexpected-immutable");
6
+ const unexpectedStyles = require("./unexpected-styles");
7
+ const unexpectedModule = require("./unexpected-module");
8
+ const unexpectedForm = require("./unexpected-form");
9
+ const React = require("react");
10
+ const Immutable = require("immutable");
11
+ const sinon = require("sinon");
12
+
13
+ global.expect = unexpected
14
+ .clone()
15
+ .use(unexpectedSinon)
16
+ .use(unexpectedImmutable)
17
+ .use(unexpectedDom)
18
+ .use(unexpectedReaction)
19
+ .use(unexpectedStyles)
20
+ .use(unexpectedModule)
21
+ .use(unexpectedForm)
22
+ .addAssertion(
23
+ "<array-like> to be shorter than [or same length as] <array-like>",
24
+ function (expect, subject, pattern) {
25
+ if (expect.flags["or same length as"]) {
26
+ return expect(subject.length, "to be less than or equal to", pattern.length);
27
+ } else {
28
+ return expect(subject.length, "to be less than", pattern.length);
29
+ }
30
+ },
31
+ )
32
+ .addAssertion("<function> to be a reducer with initial state <object>", function (expect, subject, initialState) {
33
+ expect.errorMode = "nested";
34
+ const oldState = Immutable.Map();
35
+ return expect(subject, "when called with", [oldState, { type: "NOT_A_USEFUL_ACTION" }], "to be", oldState).and(
36
+ "when called with",
37
+ [undefined, { type: "@@INIT" }],
38
+ "to equal",
39
+ Immutable.fromJS(initialState),
40
+ );
41
+ })
42
+ .addAssertion("<function> as a React component <assertion?>", function (expect, Subject, assertions) {
43
+ expect.errorMode = "bubble";
44
+ try {
45
+ const element = React.createElement(Subject);
46
+ return expect.shift(element);
47
+ } catch (e) {
48
+ return expect.fail("Could not create element. ", e.message);
49
+ }
50
+ })
51
+ .addAssertion("<any> to be a label", function (expect, subject) {
52
+ expect.errorMode = "nested";
53
+ if (typeof subject == "object") {
54
+ expect(subject, "to satisfy", {
55
+ id: expect.it("to be a string"),
56
+ defaultMessage: expect.it("to be a string"),
57
+ });
58
+ } else {
59
+ expect(subject, "to be a string");
60
+ }
61
+ })
62
+ .addAssertion("<object> to be a column definition", function (expect, subject) {
63
+ if (subject.type === "select") {
64
+ expect(subject, "to exhaustively satisfy", { type: "select" });
65
+ } else {
66
+ const pattern = {
67
+ fieldName: expect
68
+ .it("to be a string")
69
+ .or("to be an array")
70
+ .and("to have items satisfying", expect.it("to be a string").or("to be a number")),
71
+ };
72
+ if (subject.hasOwnProperty("width")) {
73
+ pattern.width = expect.it("to be a string").and("not to match", /[;:{[]/);
74
+ }
75
+ if (subject.hasOwnProperty("type")) {
76
+ pattern.type = expect
77
+ .it("to be", "number")
78
+ .or("to be", "date")
79
+ .or("to be", "datetime")
80
+ .or("to be", "currency")
81
+ .or("to be", "switch")
82
+ .or("to be", "custom");
83
+ if (subject.type === "currency") {
84
+ pattern.currency = expect
85
+ .it("to be a string")
86
+ .and("to have length", 3)
87
+ .or("to be an array")
88
+ .and("to have items satisfying", "to be a string");
89
+ }
90
+ if (subject.type === "switch" && subject.hasOwnProperty("switch")) {
91
+ pattern.switch = expect.it("to be an object");
92
+ }
93
+ if (subject.type === "custom") {
94
+ pattern.component = expect.it("to be a function");
95
+ if (subject.hasOwnProperty("funcs")) {
96
+ pattern.funcs = expect.it("to have values satisfying", "to be a function");
97
+ }
98
+ }
99
+ }
100
+ if (subject.hasOwnProperty("transform")) {
101
+ pattern.transform = expect.it("to be a function");
102
+ }
103
+ if (subject.hasOwnProperty("label")) {
104
+ pattern.label = expect.it("to be a label");
105
+ }
106
+ if (subject.hasOwnProperty("sort")) {
107
+ pattern.sort = expect.it("to be a function");
108
+ }
109
+ if (subject.hasOwnProperty("defaultValue")) {
110
+ pattern.defaultValue = expect.it("to be defined");
111
+ }
112
+ return expect(subject, "to exhaustively satisfy", pattern);
113
+ }
114
+ });
115
+
116
+ // Add stub for jsdom scrollTo function
117
+ Element.prototype.scrollTo = sinon.stub().named("Element.scrollTo");
@@ -0,0 +1,393 @@
1
+ import React from "react";
2
+
3
+ const TestComp = () => <div />;
4
+
5
+ // "<function> to be a reducer with initial state <object>"
6
+ // "<ReactShallowRenderer> has elements <assertion?>"
7
+ // "<ReactElement> renders elements <assertion>"
8
+ // "<function> as a React component <assertion?>"
9
+
10
+ describe("<any> to be a label", () => {
11
+ it("passes if subject is a string", () => expect(() => expect("Label", "to be a label"), "not to throw"));
12
+
13
+ it("passes if subject is a react-intl descriptor", () =>
14
+ expect(
15
+ () =>
16
+ expect(
17
+ {
18
+ id: "foo.test.label",
19
+ defaultMessage: "Label {foo}",
20
+ values: { foo: "A" },
21
+ },
22
+ "to be a label",
23
+ ),
24
+ "not to throw",
25
+ ));
26
+
27
+ it("fails if subject is not a string or object", () =>
28
+ expect(
29
+ () => expect(542, "to be a label"),
30
+ "to throw",
31
+ "expected 542 to be a label\n expected 542 to be a string",
32
+ ));
33
+
34
+ it("fails if subject is not a react-intl descriptor", () =>
35
+ expect(
36
+ () => expect({ id: "foo.test.label" }, "to be a label"),
37
+ "to throw",
38
+ "expected { id: 'foo.test.label' } to be a label\n" +
39
+ " expected { id: 'foo.test.label' } to satisfy\n" +
40
+ " {\n" +
41
+ " id: expect.it('to be a string'),\n" +
42
+ " defaultMessage: expect.it('to be a string')\n" +
43
+ " }\n" +
44
+ "\n" +
45
+ " {\n" +
46
+ " id: 'foo.test.label'\n" +
47
+ " // missing: defaultMessage: should be a string\n" +
48
+ " }",
49
+ ));
50
+ });
51
+
52
+ describe("<object> to be a column definition", () => {
53
+ it("passes with a select column", () =>
54
+ expect(() => expect({ type: "select" }, "to be a column definition"), "not to throw"));
55
+
56
+ it("fails if select column has other parameters", () =>
57
+ expect(
58
+ () => expect({ type: "select", label: "select" }, "to be a column definition"),
59
+ "to throw",
60
+ "expected { type: 'select', label: 'select' } to be a column definition\n" +
61
+ "\n" +
62
+ "{\n" +
63
+ " type: 'select',\n" +
64
+ " label: 'select' // should be removed\n" +
65
+ "}",
66
+ ));
67
+
68
+ it("passes with no type, string field name", () =>
69
+ expect(
70
+ () =>
71
+ expect(
72
+ {
73
+ fieldName: "ColumnA",
74
+ },
75
+ "to be a column definition",
76
+ ),
77
+ "not to throw",
78
+ ));
79
+
80
+ it("passes with no type, string field name, width", () =>
81
+ expect(
82
+ () =>
83
+ expect(
84
+ {
85
+ fieldName: "ColumnA",
86
+ width: "400px",
87
+ },
88
+ "to be a column definition",
89
+ ),
90
+ "not to throw",
91
+ ));
92
+
93
+ it("fails if width contains suspicious characters", () =>
94
+ expect(
95
+ () =>
96
+ expect(
97
+ {
98
+ fieldName: "ColumnA",
99
+ width: "400px;",
100
+ },
101
+ "to be a column definition",
102
+ ),
103
+ "to throw",
104
+ "expected { fieldName: 'ColumnA', width: '400px;' } to be a column definition\n" +
105
+ "\n" +
106
+ "{\n" +
107
+ " fieldName: 'ColumnA',\n" +
108
+ " width: '400px;' // ✓ should be a string and\n" +
109
+ " // ⨯ should not match /[;:{[]/\n" +
110
+ " //\n" +
111
+ " // 400px;\n" +
112
+ " // ^\n" +
113
+ "}",
114
+ ));
115
+
116
+ it("fails if there are unknown parameters", () =>
117
+ expect(
118
+ () =>
119
+ expect(
120
+ {
121
+ fieldName: "ColumnA",
122
+ unknownParam: true,
123
+ },
124
+ "to be a column definition",
125
+ ),
126
+ "to throw",
127
+ "expected { fieldName: 'ColumnA', unknownParam: true } to be a column definition\n" +
128
+ "\n" +
129
+ "{\n" +
130
+ " fieldName: 'ColumnA',\n" +
131
+ " unknownParam: true // should be removed\n" +
132
+ "}",
133
+ ));
134
+
135
+ it("passes with number type, array field name, transform function", () =>
136
+ expect(
137
+ () =>
138
+ expect(
139
+ {
140
+ type: "number",
141
+ fieldName: ["rowB", 3, "ColumnA"],
142
+ transform: x => x * 10,
143
+ },
144
+ "to be a column definition",
145
+ ),
146
+ "not to throw",
147
+ ));
148
+
149
+ it("fails if array field name contains non-string non-numbers", () =>
150
+ expect(
151
+ () =>
152
+ expect(
153
+ {
154
+ type: "number",
155
+ fieldName: [() => "rowB", 3, "ColumnA"],
156
+ },
157
+ "to be a column definition",
158
+ ),
159
+ "to throw",
160
+ "expected { type: 'number', fieldName: [ () => \"rowB\", 3, 'ColumnA' ] }\n" +
161
+ "to be a column definition\n" +
162
+ "\n" +
163
+ "{\n" +
164
+ " type: 'number',\n" +
165
+ " fieldName:\n" +
166
+ " [ () => \"rowB\", 3, 'ColumnA' ] // ⨯ should be a string\n" +
167
+ " // or\n" +
168
+ " // ✓ should be an array and\n" +
169
+ " // ⨯ should have items satisfying\n" +
170
+ " // expect.it('to be a string')\n" +
171
+ " // .or('to be a number')\n" +
172
+ " //\n" +
173
+ " // [\n" +
174
+ ' // () => "rowB", // ⨯ should be a string or\n' +
175
+ " // // ⨯ should be a number\n" +
176
+ " // 3,\n" +
177
+ " // 'ColumnA'\n" +
178
+ " // ]\n" +
179
+ "}",
180
+ ));
181
+
182
+ it("passes with date type and a string label", () =>
183
+ expect(
184
+ () =>
185
+ expect(
186
+ {
187
+ type: "date",
188
+ fieldName: "ColumnA",
189
+ label: "Column A",
190
+ },
191
+ "to be a column definition",
192
+ ),
193
+ "not to throw",
194
+ ));
195
+
196
+ it("passes with datetime type and a message descriptor label", () =>
197
+ expect(
198
+ () =>
199
+ expect(
200
+ {
201
+ type: "datetime",
202
+ fieldName: "ColumnA",
203
+ label: { id: "test.col_a", defaultMessage: "Column A" },
204
+ },
205
+ "to be a column definition",
206
+ ),
207
+ "not to throw",
208
+ ));
209
+
210
+ it("passes with currency type with a string currency and a sort function", () =>
211
+ expect(
212
+ () =>
213
+ expect(
214
+ {
215
+ type: "currency",
216
+ currency: "USD",
217
+ fieldName: "ColumnA",
218
+ sort: () => {},
219
+ },
220
+ "to be a column definition",
221
+ ),
222
+ "not to throw",
223
+ ));
224
+
225
+ it("fails if currency type has no currency given", () =>
226
+ expect(
227
+ () =>
228
+ expect(
229
+ {
230
+ type: "currency",
231
+ fieldName: "ColumnA",
232
+ sort: () => {},
233
+ },
234
+ "to be a column definition",
235
+ ),
236
+ "to throw",
237
+ "expected { type: 'currency', fieldName: 'ColumnA', sort: () => {} }\n" +
238
+ "to be a column definition\n" +
239
+ "\n" +
240
+ "{\n" +
241
+ " type: 'currency',\n" +
242
+ " fieldName: 'ColumnA',\n" +
243
+ " sort: () => {}\n" +
244
+ " // missing: currency: ⨯ should be a string and\n" +
245
+ " ⨯ should have length 3\n" +
246
+ " or\n" +
247
+ " ⨯ should be an array and\n" +
248
+ " ⨯ should have items satisfying 'to be a string'\n" +
249
+ "}",
250
+ ));
251
+
252
+ it("passes with currency type with a data path currency and a default value", () =>
253
+ expect(
254
+ () =>
255
+ expect(
256
+ {
257
+ type: "currency",
258
+ currency: ["data", "currency"],
259
+ fieldName: "ColumnA",
260
+ defaultValue: "12.99",
261
+ },
262
+ "to be a column definition",
263
+ ),
264
+ "not to throw",
265
+ ));
266
+
267
+ it("passes with switch type without settings", () =>
268
+ expect(
269
+ () =>
270
+ expect(
271
+ {
272
+ type: "switch",
273
+ fieldName: "ColumnA",
274
+ },
275
+ "to be a column definition",
276
+ ),
277
+ "not to throw",
278
+ ));
279
+
280
+ it("passes with switch type with settings", () =>
281
+ expect(
282
+ () =>
283
+ expect(
284
+ {
285
+ type: "switch",
286
+ fieldName: "ColumnA",
287
+ switch: {
288
+ onCaption: "On",
289
+ offCaption: "Off",
290
+ },
291
+ },
292
+ "to be a column definition",
293
+ ),
294
+ "not to throw",
295
+ ));
296
+
297
+ it("fails if switch settings found on other type", () =>
298
+ expect(
299
+ () =>
300
+ expect(
301
+ {
302
+ type: "number",
303
+ fieldName: "ColumnA",
304
+ switch: {
305
+ onCaption: "On",
306
+ offCaption: "Off",
307
+ },
308
+ },
309
+ "to be a column definition",
310
+ ),
311
+ "to throw",
312
+ "expected\n" +
313
+ "{\n" +
314
+ " type: 'number',\n" +
315
+ " fieldName: 'ColumnA',\n" +
316
+ " switch: { onCaption: 'On', offCaption: 'Off' }\n" +
317
+ "}\n" +
318
+ "to be a column definition\n" +
319
+ "\n" +
320
+ "{\n" +
321
+ " type: 'number',\n" +
322
+ " fieldName: 'ColumnA',\n" +
323
+ " switch: { onCaption: 'On', offCaption: 'Off' } // should be removed\n" +
324
+ "}",
325
+ ));
326
+
327
+ it("passes with custom type without funcs", () =>
328
+ expect(
329
+ () =>
330
+ expect(
331
+ {
332
+ type: "custom",
333
+ fieldName: "ColumnA",
334
+ component: TestComp,
335
+ },
336
+ "to be a column definition",
337
+ ),
338
+ "not to throw",
339
+ ));
340
+
341
+ it("passes with custom type with funcs", () =>
342
+ expect(
343
+ () =>
344
+ expect(
345
+ {
346
+ type: "custom",
347
+ fieldName: "ColumnA",
348
+ component: TestComp,
349
+ funcs: {
350
+ test: () => {},
351
+ },
352
+ },
353
+ "to be a column definition",
354
+ ),
355
+ "not to throw",
356
+ ));
357
+
358
+ it("fails if component or funcs on non-custom type", () =>
359
+ expect(
360
+ () =>
361
+ expect(
362
+ {
363
+ type: "date",
364
+ fieldName: "ColumnA",
365
+ component: TestComp,
366
+ funcs: {
367
+ test: () => {},
368
+ },
369
+ },
370
+ "to be a column definition",
371
+ ),
372
+ "to throw",
373
+ "expected\n" +
374
+ "{\n" +
375
+ " type: 'date',\n" +
376
+ " fieldName: 'ColumnA',\n" +
377
+ " component: " +
378
+ TestComp.toString() +
379
+ ",\n" +
380
+ " funcs: { test: () => {} }\n" +
381
+ "}\n" +
382
+ "to be a column definition\n" +
383
+ "\n" +
384
+ "{\n" +
385
+ " type: 'date',\n" +
386
+ " fieldName: 'ColumnA',\n" +
387
+ " component: " +
388
+ TestComp.toString() +
389
+ ", // should be removed\n" +
390
+ " funcs: { test: () => {} } // should be removed\n" +
391
+ "}",
392
+ ));
393
+ });