@m4l/testing 0.0.10 → 0.0.11
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.11",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "M4L Team",
|
|
7
7
|
"lint-staged": {
|
|
@@ -30,8 +30,9 @@
|
|
|
30
30
|
"@vitest/ui": "^3.1.1",
|
|
31
31
|
"cypress": "^13.14.2",
|
|
32
32
|
"cypress-vite": "^1.5.0",
|
|
33
|
-
"jsdom": "^25.0.1",
|
|
34
33
|
"happy-dom": "^17.1.9",
|
|
34
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
35
|
+
"jsdom": "^25.0.1",
|
|
35
36
|
"storybook": "^8.3.4"
|
|
36
37
|
},
|
|
37
38
|
"peerDependencies": {
|
|
@@ -2,4 +2,4 @@ import { TestingColumn, TestingColumnConfig } from './types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Test the column configs
|
|
4
4
|
*/
|
|
5
|
-
export declare const testColumnConfigs: (columns: Array<TestingColumn>, configs: readonly TestingColumnConfig[]) => void;
|
|
5
|
+
export declare const testColumnConfigs: <T>(columns: Array<TestingColumn>, configs: readonly TestingColumnConfig<T>[]) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { expect as t } from "vitest";
|
|
2
|
-
const h = (o) => o?.type === "nested",
|
|
2
|
+
const h = (o) => o?.type === "nested", d = (o) => o?.type === "date", n = (o) => o?.type === "boolean", k = (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
3
|
t(o).toHaveLength(a.length), a.forEach((e, s) => {
|
|
4
4
|
const l = o[s], u = e.hookCall?.type ?? "none";
|
|
5
5
|
describe(`Column ${s + 1}: ${e.key} (${u})`, () => {
|
|
@@ -12,17 +12,17 @@ const h = (o) => o?.type === "nested", n = (o) => o?.type === "date", k = (o) =>
|
|
|
12
12
|
t(l.testProps).toEqual({
|
|
13
13
|
fieldValue: e.hookCall.fieldValue
|
|
14
14
|
});
|
|
15
|
-
else if (
|
|
15
|
+
else if (d(e.hookCall))
|
|
16
16
|
t(l.testProps).toEqual({
|
|
17
17
|
fieldValue: e.hookCall.fieldValue,
|
|
18
18
|
presentationType: e.hookCall.presentationType
|
|
19
19
|
});
|
|
20
|
-
else if (
|
|
20
|
+
else if (n(e.hookCall))
|
|
21
21
|
t(l.testProps).toEqual({
|
|
22
22
|
fieldValue: e.hookCall.fieldValue,
|
|
23
23
|
presentationType: e.hookCall.presentationType
|
|
24
24
|
});
|
|
25
|
-
else if (
|
|
25
|
+
else if (k(e.hookCall))
|
|
26
26
|
t(l.testProps).toEqual({
|
|
27
27
|
field: e.hookCall.field,
|
|
28
28
|
disabledGetter: t.any(Function),
|
|
@@ -51,8 +51,8 @@ const h = (o) => o?.type === "nested", n = (o) => o?.type === "date", k = (o) =>
|
|
|
51
51
|
});
|
|
52
52
|
else if (m(e.hookCall))
|
|
53
53
|
t(l.testProps).toEqual({
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
fieldLabel: e.hookCall.fieldLabel,
|
|
55
|
+
fieldStatus: e.hookCall.fieldStatus,
|
|
56
56
|
statusesColors: e.hookCall.statusesColors,
|
|
57
57
|
fallbackColor: e.hookCall.fallbackColor
|
|
58
58
|
});
|
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
import { ColumnNestedValueFormatterProps, ColumnDateFormatterProps, ColumnBooleanFormatterProps, ColumnPriceFormatterProps, ColumnPointsFormatterProps, ColumnSetCheckFormatterProps, ColumnUncertaintyFormatterProps, ColumnConcatenatedValuesFormatterProps, Column, ColumnInteractiveCheckFormatterProps, ColumnChipStatusFormatterProps } from '@m4l/components';
|
|
2
|
-
type BaseColumnConfig = Column<
|
|
2
|
+
type BaseColumnConfig<T> = Column<T, unknown>;
|
|
3
3
|
type BaseHookCall = {
|
|
4
4
|
type: 'nested' | 'date' | 'boolean' | 'price' | 'points' | 'interactiveCheck' | 'setCheck' | 'uncertainty' | 'concatenated' | 'chipStatus';
|
|
5
5
|
};
|
|
6
|
-
export type TestingNestedValueHookCall = BaseHookCall & ColumnNestedValueFormatterProps & {
|
|
6
|
+
export type TestingNestedValueHookCall<T> = BaseHookCall & ColumnNestedValueFormatterProps<T> & {
|
|
7
7
|
type: 'nested';
|
|
8
8
|
};
|
|
9
|
-
export type TestingDateHookCall = BaseHookCall & ColumnDateFormatterProps & {
|
|
9
|
+
export type TestingDateHookCall<T> = BaseHookCall & ColumnDateFormatterProps<T> & {
|
|
10
10
|
type: 'date';
|
|
11
11
|
};
|
|
12
|
-
export type TestingBooleanHookCall = BaseHookCall & ColumnBooleanFormatterProps & {
|
|
12
|
+
export type TestingBooleanHookCall<T> = BaseHookCall & ColumnBooleanFormatterProps<T> & {
|
|
13
13
|
type: 'boolean';
|
|
14
14
|
};
|
|
15
|
-
export type TestingPriceHookCall = BaseHookCall & ColumnPriceFormatterProps & {
|
|
15
|
+
export type TestingPriceHookCall<T> = BaseHookCall & ColumnPriceFormatterProps<T> & {
|
|
16
16
|
type: 'price';
|
|
17
17
|
};
|
|
18
|
-
export type TestingPointsHookCall = BaseHookCall & ColumnPointsFormatterProps & {
|
|
18
|
+
export type TestingPointsHookCall<T> = BaseHookCall & ColumnPointsFormatterProps<T> & {
|
|
19
19
|
type: 'points';
|
|
20
20
|
};
|
|
21
|
-
export type TestingInteractiveCheckHookCall = BaseHookCall & ColumnInteractiveCheckFormatterProps<
|
|
21
|
+
export type TestingInteractiveCheckHookCall<T> = BaseHookCall & ColumnInteractiveCheckFormatterProps<T> & {
|
|
22
22
|
type: 'interactiveCheck';
|
|
23
23
|
};
|
|
24
|
-
export type TestingSetCheckHookCall = BaseHookCall & ColumnSetCheckFormatterProps<
|
|
24
|
+
export type TestingSetCheckHookCall<T> = BaseHookCall & ColumnSetCheckFormatterProps<T> & {
|
|
25
25
|
type: 'setCheck';
|
|
26
26
|
};
|
|
27
|
-
export type TestingUncertaintyHookCall = BaseHookCall & ColumnUncertaintyFormatterProps & {
|
|
27
|
+
export type TestingUncertaintyHookCall<T> = BaseHookCall & ColumnUncertaintyFormatterProps<T> & {
|
|
28
28
|
type: 'uncertainty';
|
|
29
29
|
};
|
|
30
|
-
export type TestingConcatenatedHookCall = BaseHookCall & ColumnConcatenatedValuesFormatterProps & {
|
|
30
|
+
export type TestingConcatenatedHookCall<T> = BaseHookCall & ColumnConcatenatedValuesFormatterProps<T> & {
|
|
31
31
|
type: 'concatenated';
|
|
32
32
|
};
|
|
33
|
-
export type TestingChipStatusHookCall = BaseHookCall & ColumnChipStatusFormatterProps<
|
|
33
|
+
export type TestingChipStatusHookCall<T> = BaseHookCall & ColumnChipStatusFormatterProps<T> & {
|
|
34
34
|
type: 'chipStatus';
|
|
35
35
|
};
|
|
36
|
-
export type TestingColumnConfig = BaseColumnConfig & {
|
|
37
|
-
hookCall?: TestingNestedValueHookCall | TestingDateHookCall | TestingBooleanHookCall | TestingPriceHookCall | TestingPointsHookCall | TestingInteractiveCheckHookCall | TestingSetCheckHookCall | TestingUncertaintyHookCall | TestingConcatenatedHookCall | TestingChipStatusHookCall
|
|
36
|
+
export type TestingColumnConfig<T> = BaseColumnConfig<T> & {
|
|
37
|
+
hookCall?: TestingNestedValueHookCall<T> | TestingDateHookCall<T> | TestingBooleanHookCall<T> | TestingPriceHookCall<T> | TestingPointsHookCall<T> | TestingInteractiveCheckHookCall<T> | TestingSetCheckHookCall<T> | TestingUncertaintyHookCall<T> | TestingConcatenatedHookCall<T> | TestingChipStatusHookCall<T>;
|
|
38
38
|
};
|
|
39
39
|
export type TestingColumn = Column<unknown, unknown> & {
|
|
40
40
|
testProps?: Record<string, unknown>;
|