@m4l/testing 0.0.9 → 0.0.10-beta.2
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m4l/testing",
|
|
3
3
|
"description": "Shared testing utilities for MFs",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.10-beta.2",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "M4L Team",
|
|
7
7
|
"lint-staged": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"cypress": "^13.14.2",
|
|
32
32
|
"cypress-vite": "^1.5.0",
|
|
33
33
|
"jsdom": "^25.0.1",
|
|
34
|
+
"happy-dom": "^17.1.9",
|
|
34
35
|
"storybook": "^8.3.4"
|
|
35
36
|
},
|
|
36
37
|
"peerDependencies": {
|
|
@@ -1,28 +1,73 @@
|
|
|
1
1
|
import { expect as t } from "vitest";
|
|
2
|
-
const
|
|
3
|
-
t(
|
|
4
|
-
const
|
|
5
|
-
describe(`Column ${s + 1}: ${e.key} (${
|
|
6
|
-
it("should have the correct basic properties", () => {
|
|
7
|
-
t(
|
|
8
|
-
}), e.hookCall
|
|
9
|
-
i
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
const h = (o) => o?.type === "nested", n = (o) => o?.type === "date", k = (o) => o?.type === "boolean", d = (o) => o?.type === "setCheck", C = (o) => o?.type === "price", p = (o) => o?.type === "points", y = (o) => o?.type === "uncertainty", f = (o) => o?.type === "concatenated", m = (o) => o?.type === "chipStatus", V = (o, a) => {
|
|
3
|
+
t(o).toHaveLength(a.length), a.forEach((e, s) => {
|
|
4
|
+
const l = o[s], u = e.hookCall?.type ?? "none";
|
|
5
|
+
describe(`Column ${s + 1}: ${e.key} (${u})`, () => {
|
|
6
|
+
if (it("should have the correct basic properties", () => {
|
|
7
|
+
t(l.key).toBe(e.key), t(l.name).toBe(e.name), t(l.type).toBe(e.type), t(l.align).toBe(e.align), t(l.width).toBe(e.width), t(l.visible).toBe(e.visible), e.fixed && t(l.fixed).toBe(e.fixed);
|
|
8
|
+
}), e.hookCall) {
|
|
9
|
+
let r = !0, i = !0;
|
|
10
|
+
it("should have the correct hook call properties", () => {
|
|
11
|
+
if (h(e.hookCall))
|
|
12
|
+
t(l.testProps).toEqual({
|
|
13
|
+
fieldValue: e.hookCall.fieldValue
|
|
14
|
+
});
|
|
15
|
+
else if (n(e.hookCall))
|
|
16
|
+
t(l.testProps).toEqual({
|
|
17
|
+
fieldValue: e.hookCall.fieldValue,
|
|
18
|
+
presentationType: e.hookCall.presentationType
|
|
19
|
+
});
|
|
20
|
+
else if (k(e.hookCall))
|
|
21
|
+
t(l.testProps).toEqual({
|
|
22
|
+
fieldValue: e.hookCall.fieldValue,
|
|
23
|
+
presentationType: e.hookCall.presentationType
|
|
24
|
+
});
|
|
25
|
+
else if (d(e.hookCall))
|
|
26
|
+
t(l.testProps).toEqual({
|
|
27
|
+
field: e.hookCall.field,
|
|
28
|
+
disabledGetter: t.any(Function),
|
|
29
|
+
rowKeyGetter: t.any(Function),
|
|
30
|
+
useHook: t.any(Function)
|
|
31
|
+
}), r = !1, i = !1;
|
|
32
|
+
else if (C(e.hookCall))
|
|
33
|
+
t(l.testProps).toEqual({
|
|
34
|
+
fieldValue: e.hookCall.fieldValue
|
|
35
|
+
});
|
|
36
|
+
else if (p(e.hookCall))
|
|
37
|
+
t(l.testProps).toEqual({
|
|
38
|
+
fieldValue: e.hookCall.fieldValue,
|
|
39
|
+
fieldUnit: e.hookCall.fieldUnit
|
|
40
|
+
});
|
|
41
|
+
else if (y(e.hookCall))
|
|
42
|
+
t(l.testProps).toEqual({
|
|
43
|
+
fieldValue: e.hookCall.fieldValue,
|
|
44
|
+
fieldUnit: e.hookCall.fieldUnit,
|
|
45
|
+
fieldSymbol: e.hookCall.fieldSymbol
|
|
46
|
+
});
|
|
47
|
+
else if (f(e.hookCall))
|
|
48
|
+
t(l.testProps).toEqual({
|
|
49
|
+
fieldValue: e.hookCall.fieldValue,
|
|
50
|
+
fieldSeparator: e.hookCall.fieldSeparator
|
|
51
|
+
});
|
|
52
|
+
else if (m(e.hookCall))
|
|
53
|
+
t(l.testProps).toEqual({
|
|
54
|
+
uriLabel: e.hookCall.uriLabel,
|
|
55
|
+
uriStatus: e.hookCall.uriStatus,
|
|
56
|
+
statusesColors: e.hookCall.statusesColors,
|
|
57
|
+
fallbackColor: e.hookCall.fallbackColor
|
|
58
|
+
});
|
|
59
|
+
else
|
|
60
|
+
throw new Error(`Unknown hook call type: ${e.hookCall?.type}`);
|
|
61
|
+
}), it("should have formatter, customFilter and customSort functions", () => {
|
|
62
|
+
t(l.formatter).toBeDefined(), r && t(l.customFilter).toBeDefined(), i && t(l.customSort).toBeDefined();
|
|
63
|
+
});
|
|
64
|
+
} else
|
|
65
|
+
it("should not have formatter functions", () => {
|
|
66
|
+
t(l.formatter).toBeUndefined(), t(l.customFilter).toBeUndefined(), t(l.customSort).toBeUndefined();
|
|
17
67
|
});
|
|
18
|
-
}), it("should have formatter, customFilter and customSort functions", () => {
|
|
19
|
-
t(o.formatter).toBeDefined(), t(o.customFilter).toBeDefined(), t(o.customSort).toBeDefined();
|
|
20
|
-
})) : it("should not have formatter functions", () => {
|
|
21
|
-
t(o.formatter).toBeUndefined(), t(o.customFilter).toBeUndefined(), t(o.customSort).toBeUndefined();
|
|
22
|
-
});
|
|
23
68
|
});
|
|
24
69
|
});
|
|
25
70
|
};
|
|
26
71
|
export {
|
|
27
|
-
|
|
72
|
+
V as t
|
|
28
73
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ColumnNestedValueFormatterProps, ColumnDateFormatterProps, ColumnBooleanFormatterProps, ColumnPriceFormatterProps, ColumnPointsFormatterProps, ColumnSetCheckFormatterProps, ColumnUncertaintyFormatterProps, ColumnConcatenatedValuesFormatterProps, Column } from '@m4l/components';
|
|
1
|
+
import { ColumnNestedValueFormatterProps, ColumnDateFormatterProps, ColumnBooleanFormatterProps, ColumnPriceFormatterProps, ColumnPointsFormatterProps, ColumnSetCheckFormatterProps, ColumnUncertaintyFormatterProps, ColumnConcatenatedValuesFormatterProps, Column, ColumnInteractiveCheckFormatterProps, ColumnChipStatusFormatterProps } from '@m4l/components';
|
|
2
2
|
type BaseColumnConfig = Column<unknown, unknown>;
|
|
3
3
|
type BaseHookCall = {
|
|
4
|
-
type: 'nested' | 'date' | 'boolean' | 'price' | 'points' | 'interactiveCheck' | 'setCheck' | 'uncertainty' | 'concatenated';
|
|
4
|
+
type: 'nested' | 'date' | 'boolean' | 'price' | 'points' | 'interactiveCheck' | 'setCheck' | 'uncertainty' | 'concatenated' | 'chipStatus';
|
|
5
5
|
};
|
|
6
6
|
export type TestingNestedValueHookCall = BaseHookCall & ColumnNestedValueFormatterProps & {
|
|
7
7
|
type: 'nested';
|
|
@@ -18,7 +18,7 @@ export type TestingPriceHookCall = BaseHookCall & ColumnPriceFormatterProps & {
|
|
|
18
18
|
export type TestingPointsHookCall = BaseHookCall & ColumnPointsFormatterProps & {
|
|
19
19
|
type: 'points';
|
|
20
20
|
};
|
|
21
|
-
export type TestingInteractiveCheckHookCall = BaseHookCall & {
|
|
21
|
+
export type TestingInteractiveCheckHookCall = BaseHookCall & ColumnInteractiveCheckFormatterProps<unknown> & {
|
|
22
22
|
type: 'interactiveCheck';
|
|
23
23
|
};
|
|
24
24
|
export type TestingSetCheckHookCall = BaseHookCall & ColumnSetCheckFormatterProps<unknown> & {
|
|
@@ -30,8 +30,11 @@ export type TestingUncertaintyHookCall = BaseHookCall & ColumnUncertaintyFormatt
|
|
|
30
30
|
export type TestingConcatenatedHookCall = BaseHookCall & ColumnConcatenatedValuesFormatterProps & {
|
|
31
31
|
type: 'concatenated';
|
|
32
32
|
};
|
|
33
|
+
export type TestingChipStatusHookCall = BaseHookCall & ColumnChipStatusFormatterProps<unknown> & {
|
|
34
|
+
type: 'chipStatus';
|
|
35
|
+
};
|
|
33
36
|
export type TestingColumnConfig = BaseColumnConfig & {
|
|
34
|
-
hookCall?: TestingNestedValueHookCall | TestingDateHookCall | TestingBooleanHookCall | TestingPriceHookCall | TestingPointsHookCall | TestingInteractiveCheckHookCall | TestingSetCheckHookCall | TestingUncertaintyHookCall | TestingConcatenatedHookCall;
|
|
37
|
+
hookCall?: TestingNestedValueHookCall | TestingDateHookCall | TestingBooleanHookCall | TestingPriceHookCall | TestingPointsHookCall | TestingInteractiveCheckHookCall | TestingSetCheckHookCall | TestingUncertaintyHookCall | TestingConcatenatedHookCall | TestingChipStatusHookCall;
|
|
35
38
|
};
|
|
36
39
|
export type TestingColumn = Column<unknown, unknown> & {
|
|
37
40
|
testProps?: Record<string, unknown>;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { it as h, expect as r, describe as s } from "vitest";
|
|
2
|
-
const
|
|
2
|
+
const B = (n, a) => {
|
|
3
3
|
h("should return an array with the correct length", () => {
|
|
4
4
|
r(Array.isArray(n)).toBe(!0), r(n.length).toBe(a.length);
|
|
5
|
-
}), a.forEach((
|
|
6
|
-
const
|
|
7
|
-
s(`Field ${e + 1}: ${
|
|
5
|
+
}), a.forEach((o, e) => {
|
|
6
|
+
const t = n[e];
|
|
7
|
+
s(`Field ${e + 1}: ${o.name}`, () => {
|
|
8
8
|
h("should have the correct basic properties", () => {
|
|
9
|
-
r(
|
|
9
|
+
r(t).toBeDefined(), r(t.name).toBe(o.name), r(t.dictionaryId).toBe(o.dictionaryId), r(t.type).toBe(o.type), r(t.presence).toBe(o.presence), o.urlIcon && r(t.urlIcon).toBe(o.urlIcon);
|
|
10
10
|
});
|
|
11
11
|
});
|
|
12
12
|
});
|
|
13
13
|
};
|
|
14
14
|
export {
|
|
15
|
-
|
|
15
|
+
B as t
|
|
16
16
|
};
|