@griddo/ax 12.4.0 → 12.5.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/config/webpack.config.js +5 -0
- package/package.json +2 -2
- package/src/__tests__/components/ConfigPanel/Form/Form.test.tsx +47 -57
- package/src/__tests__/components/ConfigPanel/Header/Header.test.tsx +46 -42
- package/src/__tests__/components/ElementsTooltip/ElementsTooltip.test.tsx +6 -17
- package/src/__tests__/components/EmptyState/EmptyState.test.tsx +9 -9
- package/src/__tests__/components/Fields/AsyncSelect/AsyncSelect.test.tsx +60 -50
- package/src/__tests__/components/Fields/ColorPicker/ColorPicker.test.tsx +66 -58
- package/src/__tests__/components/Fields/ComponentContainer/ComponentContainer.test.tsx +222 -425
- package/src/__tests__/components/Fields/FileField/FileField.test.tsx +13 -14
- package/src/__tests__/components/Fields/ImageField/ImageField.test.tsx +275 -259
- package/src/__tests__/components/Fields/IntegrationsField/IntegrationsField.test.tsx +50 -48
- package/src/__tests__/components/Fields/NoteField/NoteField.test.tsx +9 -8
- package/src/__tests__/components/Fields/NumberField/NumberField.test.tsx +8 -12
- package/src/__tests__/components/Fields/TextArea/TextArea.test.tsx +6 -2
- package/src/__tests__/components/Fields/ToggleField/ToggleField.test.tsx +15 -23
- package/src/__tests__/components/Fields/Tooltip/Tooltip.test.tsx +8 -2
- package/src/__tests__/components/Fields/VisualUniqueSelection/VisualUniqueSelection.test.tsx +29 -21
- package/src/__tests__/components/Fields/Wysiwyg/Wysiwyg.config.test.tsx +103 -0
- package/src/__tests__/components/FieldsBehavior/FieldsBehavior.test.tsx +7 -2
- package/src/__tests__/components/ResizePanel/ResizePanel.test.tsx +8 -6
- package/src/__tests__/components/SideModal/SideModal.test.tsx +150 -104
- package/src/__tests__/components/TableFilters/LiveFilter/LiveFilter.test.tsx +15 -29
- package/src/__tests__/components/TableFilters/StatusFilter/StatusFilter.test.tsx +61 -36
- package/src/__tests__/components/Tabs/Tabs.test.tsx +65 -61
- package/src/__tests__/components/Toast/Toast.test.tsx +19 -21
- package/src/__tests__/modules/FramePreview/FramePreview.test.tsx +16 -0
- package/src/__tests__/modules/Sites/SitesList/ListView/BulkHeader/BulkHeader.test.tsx +24 -19
- package/src/__tests__/modules/Sites/SitesList/SitesList.test.tsx +15 -6
- package/src/__tests__/modules/Users/Roles/BulkHeader/BulkHeader.test.tsx +69 -64
- package/src/__tests__/modules/Users/Roles/Roles.test.tsx +7 -4
- package/src/components/Fields/Wysiwyg/config.tsx +68 -17
- package/src/components/Fields/Wysiwyg/helpers.tsx +2 -0
- package/src/components/Fields/Wysiwyg/index.tsx +41 -10
- package/src/components/ResizePanel/index.tsx +7 -2
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { wysiwygConfig } from "@ax/components/Fields/Wysiwyg/config";
|
|
2
|
+
|
|
3
|
+
import { config } from "components";
|
|
4
|
+
|
|
5
|
+
const schemasConfig = config.schemas.config;
|
|
6
|
+
|
|
7
|
+
// the module reads the instance config lazily, on every call, so setting it
|
|
8
|
+
// on the mocked schemas is enough: no need to reload the module
|
|
9
|
+
const loadConfigWith = (richTextConfig: unknown) => {
|
|
10
|
+
schemasConfig.richTextConfig = richTextConfig;
|
|
11
|
+
return { wysiwygConfig };
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
describe("Wysiwyg config", () => {
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
delete schemasConfig.richTextConfig;
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
describe("imageStyles", () => {
|
|
20
|
+
const imageStyles = [
|
|
21
|
+
{ label: "Rounded", className: "img-rounded" },
|
|
22
|
+
{ label: "Bordered", className: "img-bordered" },
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
it("should pass the configured image classes to Froala as a className map", () => {
|
|
26
|
+
const { wysiwygConfig } = loadConfigWith({ imageStyles });
|
|
27
|
+
|
|
28
|
+
expect(wysiwygConfig().imageStyles).toEqual({
|
|
29
|
+
"img-rounded": "Rounded",
|
|
30
|
+
"img-bordered": "Bordered",
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("should add the imageStyle button when image classes are configured", () => {
|
|
35
|
+
const { wysiwygConfig } = loadConfigWith({ imageStyles });
|
|
36
|
+
|
|
37
|
+
expect(wysiwygConfig().imageEditButtons).toContain("imageStyle");
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("should not add the imageStyle button when no image classes are configured", () => {
|
|
41
|
+
const { wysiwygConfig } = loadConfigWith({ paragraphStyles: [] });
|
|
42
|
+
|
|
43
|
+
expect(wysiwygConfig().imageStyles).toBeUndefined();
|
|
44
|
+
expect(wysiwygConfig().imageEditButtons).not.toContain("imageStyle");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("should keep the rest of the image edit buttons untouched", () => {
|
|
48
|
+
const { wysiwygConfig } = loadConfigWith({ imageStyles, imageResize: true });
|
|
49
|
+
|
|
50
|
+
expect(wysiwygConfig().imageEditButtons).toEqual([
|
|
51
|
+
"imageReplaceGriddo",
|
|
52
|
+
"imageAlign",
|
|
53
|
+
"imageCaption",
|
|
54
|
+
"imageRemove",
|
|
55
|
+
"|",
|
|
56
|
+
"imageLinkGriddo",
|
|
57
|
+
"linkOpen",
|
|
58
|
+
"linkRemove",
|
|
59
|
+
"-",
|
|
60
|
+
"imageDisplay",
|
|
61
|
+
"imageStyle",
|
|
62
|
+
"imageAlt",
|
|
63
|
+
"imageSize",
|
|
64
|
+
]);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
describe("imageResize", () => {
|
|
69
|
+
it("should enable resizing in percentages when the instance opts in", () => {
|
|
70
|
+
const { wysiwygConfig } = loadConfigWith({ imageResize: true });
|
|
71
|
+
|
|
72
|
+
expect(wysiwygConfig()).toMatchObject({
|
|
73
|
+
imageResize: true,
|
|
74
|
+
imageResizeWithPercent: true,
|
|
75
|
+
imageRoundPercent: true,
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("should add the imageSize button when the instance opts in", () => {
|
|
80
|
+
const { wysiwygConfig } = loadConfigWith({ imageResize: true });
|
|
81
|
+
|
|
82
|
+
expect(wysiwygConfig().imageEditButtons).toContain("imageSize");
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("should not resize nor show the imageSize button when the flag is missing", () => {
|
|
86
|
+
const { wysiwygConfig } = loadConfigWith({ imageStyles: [] });
|
|
87
|
+
|
|
88
|
+
expect(wysiwygConfig()).toMatchObject({
|
|
89
|
+
imageResize: false,
|
|
90
|
+
imageResizeWithPercent: false,
|
|
91
|
+
imageRoundPercent: false,
|
|
92
|
+
});
|
|
93
|
+
expect(wysiwygConfig().imageEditButtons).not.toContain("imageSize");
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("should treat an explicit false like a missing flag", () => {
|
|
97
|
+
const { wysiwygConfig } = loadConfigWith({ imageResize: false });
|
|
98
|
+
|
|
99
|
+
expect(wysiwygConfig().imageResize).toBe(false);
|
|
100
|
+
expect(wysiwygConfig().imageEditButtons).not.toContain("imageSize");
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
});
|
|
@@ -30,8 +30,13 @@ afterEach(() => {
|
|
|
30
30
|
vi.clearAllMocks();
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
-
// Default mock setup for getValidity
|
|
34
|
-
|
|
33
|
+
// Default mock setup for getValidity. Va en un beforeEach y no a nivel de
|
|
34
|
+
// módulo porque `clearAllMocks` limpia el historial de llamadas pero no el valor
|
|
35
|
+
// de retorno: los tests que lo ponen en `isValid: false` se lo dejaban puesto al
|
|
36
|
+
// siguiente.
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
mockGetValidity.mockReturnValue({ isValid: true, errorText: "" });
|
|
39
|
+
});
|
|
35
40
|
|
|
36
41
|
describe("FieldsBehavior component rendering", () => {
|
|
37
42
|
it("should render the component", () => {
|
|
@@ -28,6 +28,14 @@ vi.mock("react", async () => {
|
|
|
28
28
|
|
|
29
29
|
const useMockRef = useRef as MockedFunction<typeof useRef>;
|
|
30
30
|
|
|
31
|
+
// `useRef` está mockeado a nivel de módulo y sin implementación devuelve
|
|
32
|
+
// undefined. El primer test dejaba puesto un `mockReturnValue` que `clearMocks`
|
|
33
|
+
// no borra —solo limpia el historial de llamadas— y los dos últimos dependían
|
|
34
|
+
// de él: al reordenarlos petaban con `... reading 'current'`.
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
useMockRef.mockReturnValue({ current: {} });
|
|
37
|
+
});
|
|
38
|
+
|
|
31
39
|
describe("ResizePanel component rendering", () => {
|
|
32
40
|
it("should render the component with fixed panel", () => {
|
|
33
41
|
const defaultProps: IResizePanelProps = {
|
|
@@ -35,9 +43,6 @@ describe("ResizePanel component rendering", () => {
|
|
|
35
43
|
rightPanel: <div>Right Panel</div>,
|
|
36
44
|
};
|
|
37
45
|
|
|
38
|
-
const rightPanelRef = { current: {} };
|
|
39
|
-
useMockRef.mockReturnValue(rightPanelRef);
|
|
40
|
-
|
|
41
46
|
render(
|
|
42
47
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
43
48
|
<ResizePanel {...defaultProps} />
|
|
@@ -59,9 +64,6 @@ describe("ResizePanel component rendering", () => {
|
|
|
59
64
|
fixed: false,
|
|
60
65
|
};
|
|
61
66
|
|
|
62
|
-
const rightPanelRef = { current: {} };
|
|
63
|
-
useMockRef.mockReturnValueOnce(rightPanelRef);
|
|
64
|
-
|
|
65
67
|
render(
|
|
66
68
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
67
69
|
<ResizePanel {...defaultProps} />
|
|
@@ -16,26 +16,48 @@ vi.mock("@ax/schemas", () => ({
|
|
|
16
16
|
|
|
17
17
|
afterEach(cleanup);
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
// El escenario base es el que el primer test dejaba puesto en el objeto
|
|
20
|
+
// compartido y del que dependían los siguientes: dos categorías, dos entradas
|
|
21
|
+
// en la whiteList y el modal abierto.
|
|
22
|
+
const makeProps = (overrides: Partial<ISideModalProps> = {}): ISideModalProps =>
|
|
23
|
+
Object.assign(
|
|
24
|
+
mock<ISideModalProps>(),
|
|
25
|
+
{
|
|
26
|
+
categories: [
|
|
27
|
+
{ featured: true, label: "All", value: "all" },
|
|
28
|
+
{ label: "Articles And Events", value: "articlesAndEvents" },
|
|
29
|
+
],
|
|
30
|
+
isOpen: true,
|
|
31
|
+
theme: "default-theme",
|
|
32
|
+
whiteList: ["EventsDistributor", "ArticlesDistributor"],
|
|
33
|
+
onClick: vi.fn(),
|
|
34
|
+
toggleModal: vi.fn(),
|
|
35
|
+
optionsType: "modules",
|
|
36
|
+
},
|
|
37
|
+
overrides,
|
|
38
|
+
);
|
|
20
39
|
|
|
21
40
|
describe("SideModal component rendering", () => {
|
|
22
41
|
it("should render the component visible if isOpen is true", () => {
|
|
23
42
|
const handleClickMock = vi.fn();
|
|
24
43
|
const toggleModalMock = vi.fn() as CalledWithMock<void, []> & (() => void);
|
|
25
|
-
defaultProps.categories = [
|
|
26
|
-
{ featured: true, label: "All", value: "all" },
|
|
27
|
-
{ label: "Articles And Events", value: "articlesAndEvents" },
|
|
28
|
-
];
|
|
29
|
-
defaultProps.isOpen = true;
|
|
30
|
-
defaultProps.theme = "default-theme";
|
|
31
|
-
defaultProps.whiteList = ["EventsDistributor", "ArticlesDistributor"];
|
|
32
|
-
defaultProps.onClick = handleClickMock;
|
|
33
|
-
defaultProps.toggleModal = toggleModalMock;
|
|
34
|
-
defaultProps.optionsType = "modules";
|
|
35
44
|
|
|
36
45
|
render(
|
|
37
46
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
38
|
-
<SideModal
|
|
47
|
+
<SideModal
|
|
48
|
+
{...makeProps({
|
|
49
|
+
categories: [
|
|
50
|
+
{ featured: true, label: "All", value: "all" },
|
|
51
|
+
{ label: "Articles And Events", value: "articlesAndEvents" },
|
|
52
|
+
],
|
|
53
|
+
isOpen: true,
|
|
54
|
+
theme: "default-theme",
|
|
55
|
+
whiteList: ["EventsDistributor", "ArticlesDistributor"],
|
|
56
|
+
onClick: handleClickMock,
|
|
57
|
+
toggleModal: toggleModalMock,
|
|
58
|
+
optionsType: "modules",
|
|
59
|
+
})}
|
|
60
|
+
/>
|
|
39
61
|
</ThemeProvider>,
|
|
40
62
|
);
|
|
41
63
|
|
|
@@ -48,20 +70,23 @@ describe("SideModal component rendering", () => {
|
|
|
48
70
|
it("should render the component hidden if isOpen is false", () => {
|
|
49
71
|
const handleClickMock = vi.fn();
|
|
50
72
|
const toggleModalMock = vi.fn() as CalledWithMock<void, []> & (() => void);
|
|
51
|
-
defaultProps.categories = [
|
|
52
|
-
{ featured: true, label: "All", value: "all" },
|
|
53
|
-
{ label: "Articles And Events", value: "articlesAndEvents" },
|
|
54
|
-
];
|
|
55
|
-
defaultProps.isOpen = false;
|
|
56
|
-
defaultProps.theme = "default-theme";
|
|
57
|
-
defaultProps.whiteList = ["EventsDistributor", "ArticlesDistributor"];
|
|
58
|
-
defaultProps.onClick = handleClickMock;
|
|
59
|
-
defaultProps.toggleModal = toggleModalMock;
|
|
60
|
-
defaultProps.optionsType = "modules";
|
|
61
73
|
|
|
62
74
|
render(
|
|
63
75
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
64
|
-
<SideModal
|
|
76
|
+
<SideModal
|
|
77
|
+
{...makeProps({
|
|
78
|
+
categories: [
|
|
79
|
+
{ featured: true, label: "All", value: "all" },
|
|
80
|
+
{ label: "Articles And Events", value: "articlesAndEvents" },
|
|
81
|
+
],
|
|
82
|
+
isOpen: false,
|
|
83
|
+
theme: "default-theme",
|
|
84
|
+
whiteList: ["EventsDistributor", "ArticlesDistributor"],
|
|
85
|
+
onClick: handleClickMock,
|
|
86
|
+
toggleModal: toggleModalMock,
|
|
87
|
+
optionsType: "modules",
|
|
88
|
+
})}
|
|
89
|
+
/>
|
|
65
90
|
</ThemeProvider>,
|
|
66
91
|
);
|
|
67
92
|
|
|
@@ -72,10 +97,9 @@ describe("SideModal component rendering", () => {
|
|
|
72
97
|
});
|
|
73
98
|
|
|
74
99
|
it("should render optiontype as title", () => {
|
|
75
|
-
defaultProps.isOpen = true;
|
|
76
100
|
render(
|
|
77
101
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
78
|
-
<SideModal {...
|
|
102
|
+
<SideModal {...makeProps({ isOpen: true })} />
|
|
79
103
|
</ThemeProvider>,
|
|
80
104
|
);
|
|
81
105
|
|
|
@@ -87,7 +111,7 @@ describe("SideModal component rendering", () => {
|
|
|
87
111
|
it("should render close button", () => {
|
|
88
112
|
render(
|
|
89
113
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
90
|
-
<SideModal {...
|
|
114
|
+
<SideModal {...makeProps()} />
|
|
91
115
|
</ThemeProvider>,
|
|
92
116
|
);
|
|
93
117
|
|
|
@@ -98,7 +122,7 @@ describe("SideModal component rendering", () => {
|
|
|
98
122
|
it("should render options", () => {
|
|
99
123
|
render(
|
|
100
124
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
101
|
-
<SideModal {...
|
|
125
|
+
<SideModal {...makeProps()} />
|
|
102
126
|
</ThemeProvider>,
|
|
103
127
|
);
|
|
104
128
|
|
|
@@ -110,7 +134,7 @@ describe("SideModal component rendering", () => {
|
|
|
110
134
|
it("should render option thumbnails", () => {
|
|
111
135
|
render(
|
|
112
136
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
113
|
-
<SideModal {...
|
|
137
|
+
<SideModal {...makeProps()} />
|
|
114
138
|
</ThemeProvider>,
|
|
115
139
|
);
|
|
116
140
|
|
|
@@ -122,21 +146,24 @@ describe("SideModal component rendering", () => {
|
|
|
122
146
|
it("should render all options when All filter is selected", () => {
|
|
123
147
|
const handleClickMock = vi.fn();
|
|
124
148
|
const toggleModalMock = vi.fn() as CalledWithMock<void, []> & (() => void);
|
|
125
|
-
defaultProps.categories = [
|
|
126
|
-
{ featured: true, label: "All", value: "all" },
|
|
127
|
-
{ label: "Content", value: "content" },
|
|
128
|
-
{ label: "Collections", value: "collections" },
|
|
129
|
-
];
|
|
130
|
-
defaultProps.isOpen = true;
|
|
131
|
-
defaultProps.theme = "default-theme";
|
|
132
|
-
defaultProps.whiteList = ["BasicContent", "CardCollection"];
|
|
133
|
-
defaultProps.onClick = handleClickMock;
|
|
134
|
-
defaultProps.toggleModal = toggleModalMock;
|
|
135
|
-
defaultProps.optionsType = "modules";
|
|
136
149
|
|
|
137
150
|
render(
|
|
138
151
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
139
|
-
<SideModal
|
|
152
|
+
<SideModal
|
|
153
|
+
{...makeProps({
|
|
154
|
+
categories: [
|
|
155
|
+
{ featured: true, label: "All", value: "all" },
|
|
156
|
+
{ label: "Content", value: "content" },
|
|
157
|
+
{ label: "Collections", value: "collections" },
|
|
158
|
+
],
|
|
159
|
+
isOpen: true,
|
|
160
|
+
theme: "default-theme",
|
|
161
|
+
whiteList: ["BasicContent", "CardCollection"],
|
|
162
|
+
onClick: handleClickMock,
|
|
163
|
+
toggleModal: toggleModalMock,
|
|
164
|
+
optionsType: "modules",
|
|
165
|
+
})}
|
|
166
|
+
/>
|
|
140
167
|
</ThemeProvider>,
|
|
141
168
|
);
|
|
142
169
|
const filters = screen.getAllByTestId("side-modal-nav-link");
|
|
@@ -158,20 +185,23 @@ describe("SideModal component rendering", () => {
|
|
|
158
185
|
it("should render components modal if option type is components", () => {
|
|
159
186
|
const handleClickMock = vi.fn();
|
|
160
187
|
const toggleModalMock = vi.fn() as CalledWithMock<void, []> & (() => void);
|
|
161
|
-
defaultProps.componentOptions = {
|
|
162
|
-
image: { component: "LinkableImage", editorID: 11, parentEditorID: 6 },
|
|
163
|
-
video: { component: "Video", editorID: 12, parentEditorID: 6 },
|
|
164
|
-
};
|
|
165
|
-
defaultProps.isOpen = true;
|
|
166
|
-
defaultProps.theme = "default-theme";
|
|
167
|
-
defaultProps.whiteList = ["LinkableImage", "Video"];
|
|
168
|
-
defaultProps.onClick = handleClickMock;
|
|
169
|
-
defaultProps.toggleModal = toggleModalMock;
|
|
170
|
-
defaultProps.optionsType = "components";
|
|
171
188
|
|
|
172
189
|
render(
|
|
173
190
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
174
|
-
<SideModal
|
|
191
|
+
<SideModal
|
|
192
|
+
{...makeProps({
|
|
193
|
+
componentOptions: {
|
|
194
|
+
image: { component: "LinkableImage", editorID: 11, parentEditorID: 6 },
|
|
195
|
+
video: { component: "Video", editorID: 12, parentEditorID: 6 },
|
|
196
|
+
},
|
|
197
|
+
isOpen: true,
|
|
198
|
+
theme: "default-theme",
|
|
199
|
+
whiteList: ["LinkableImage", "Video"],
|
|
200
|
+
onClick: handleClickMock,
|
|
201
|
+
toggleModal: toggleModalMock,
|
|
202
|
+
optionsType: "components",
|
|
203
|
+
})}
|
|
204
|
+
/>
|
|
175
205
|
</ThemeProvider>,
|
|
176
206
|
);
|
|
177
207
|
const options = screen.getAllByTestId("side-modal-option");
|
|
@@ -184,21 +214,24 @@ describe("SideModal component events", () => {
|
|
|
184
214
|
it("should call handle click and toggle modal on click option", () => {
|
|
185
215
|
const handleClickMock = vi.fn();
|
|
186
216
|
const toggleModalMock = vi.fn() as CalledWithMock<void, []> & (() => void);
|
|
187
|
-
defaultProps.categories = [
|
|
188
|
-
{ featured: true, label: "All", value: "all" },
|
|
189
|
-
{ label: "Articles And Events", value: "articlesAndEvents" },
|
|
190
|
-
];
|
|
191
|
-
defaultProps.componentOptions = undefined;
|
|
192
|
-
defaultProps.isOpen = true;
|
|
193
|
-
defaultProps.theme = "default-theme";
|
|
194
|
-
defaultProps.whiteList = ["Accordion", "AddressCollection"];
|
|
195
|
-
defaultProps.onClick = handleClickMock;
|
|
196
|
-
defaultProps.toggleModal = toggleModalMock;
|
|
197
|
-
defaultProps.optionsType = "modules";
|
|
198
217
|
|
|
199
218
|
render(
|
|
200
219
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
201
|
-
<SideModal
|
|
220
|
+
<SideModal
|
|
221
|
+
{...makeProps({
|
|
222
|
+
categories: [
|
|
223
|
+
{ featured: true, label: "All", value: "all" },
|
|
224
|
+
{ label: "Articles And Events", value: "articlesAndEvents" },
|
|
225
|
+
],
|
|
226
|
+
componentOptions: undefined,
|
|
227
|
+
isOpen: true,
|
|
228
|
+
theme: "default-theme",
|
|
229
|
+
whiteList: ["Accordion", "AddressCollection"],
|
|
230
|
+
onClick: handleClickMock,
|
|
231
|
+
toggleModal: toggleModalMock,
|
|
232
|
+
optionsType: "modules",
|
|
233
|
+
})}
|
|
234
|
+
/>
|
|
202
235
|
</ThemeProvider>,
|
|
203
236
|
);
|
|
204
237
|
|
|
@@ -214,21 +247,24 @@ describe("SideModal component events", () => {
|
|
|
214
247
|
it("should select filter on click", () => {
|
|
215
248
|
const handleClickMock = vi.fn();
|
|
216
249
|
const toggleModalMock = vi.fn() as CalledWithMock<void, []> & (() => void);
|
|
217
|
-
defaultProps.categories = [
|
|
218
|
-
{ featured: true, label: "All", value: "all" },
|
|
219
|
-
{ label: "Content", value: "content" },
|
|
220
|
-
{ label: "Collections", value: "collections" },
|
|
221
|
-
];
|
|
222
|
-
defaultProps.isOpen = true;
|
|
223
|
-
defaultProps.theme = "default-theme";
|
|
224
|
-
defaultProps.whiteList = ["BasicContent", "CardCollection"];
|
|
225
|
-
defaultProps.onClick = handleClickMock;
|
|
226
|
-
defaultProps.toggleModal = toggleModalMock;
|
|
227
|
-
defaultProps.optionsType = "modules";
|
|
228
250
|
|
|
229
251
|
render(
|
|
230
252
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
231
|
-
<SideModal
|
|
253
|
+
<SideModal
|
|
254
|
+
{...makeProps({
|
|
255
|
+
categories: [
|
|
256
|
+
{ featured: true, label: "All", value: "all" },
|
|
257
|
+
{ label: "Content", value: "content" },
|
|
258
|
+
{ label: "Collections", value: "collections" },
|
|
259
|
+
],
|
|
260
|
+
isOpen: true,
|
|
261
|
+
theme: "default-theme",
|
|
262
|
+
whiteList: ["BasicContent", "CardCollection"],
|
|
263
|
+
onClick: handleClickMock,
|
|
264
|
+
toggleModal: toggleModalMock,
|
|
265
|
+
optionsType: "modules",
|
|
266
|
+
})}
|
|
267
|
+
/>
|
|
232
268
|
</ThemeProvider>,
|
|
233
269
|
);
|
|
234
270
|
|
|
@@ -253,21 +289,24 @@ describe("SideModal component events", () => {
|
|
|
253
289
|
it("should filter by category on click", () => {
|
|
254
290
|
const handleClickMock = vi.fn();
|
|
255
291
|
const toggleModalMock = vi.fn() as CalledWithMock<void, []> & (() => void);
|
|
256
|
-
defaultProps.categories = [
|
|
257
|
-
{ featured: true, label: "All", value: "all" },
|
|
258
|
-
{ label: "Content", value: "content" },
|
|
259
|
-
{ label: "Collections", value: "collections" },
|
|
260
|
-
];
|
|
261
|
-
defaultProps.isOpen = true;
|
|
262
|
-
defaultProps.theme = "default-theme";
|
|
263
|
-
defaultProps.whiteList = ["BasicContent", "CardCollection"];
|
|
264
|
-
defaultProps.onClick = handleClickMock;
|
|
265
|
-
defaultProps.toggleModal = toggleModalMock;
|
|
266
|
-
defaultProps.optionsType = "modules";
|
|
267
292
|
|
|
268
293
|
render(
|
|
269
294
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
270
|
-
<SideModal
|
|
295
|
+
<SideModal
|
|
296
|
+
{...makeProps({
|
|
297
|
+
categories: [
|
|
298
|
+
{ featured: true, label: "All", value: "all" },
|
|
299
|
+
{ label: "Content", value: "content" },
|
|
300
|
+
{ label: "Collections", value: "collections" },
|
|
301
|
+
],
|
|
302
|
+
isOpen: true,
|
|
303
|
+
theme: "default-theme",
|
|
304
|
+
whiteList: ["BasicContent", "CardCollection"],
|
|
305
|
+
onClick: handleClickMock,
|
|
306
|
+
toggleModal: toggleModalMock,
|
|
307
|
+
optionsType: "modules",
|
|
308
|
+
})}
|
|
309
|
+
/>
|
|
271
310
|
</ThemeProvider>,
|
|
272
311
|
);
|
|
273
312
|
|
|
@@ -285,22 +324,25 @@ describe("SideModal component events", () => {
|
|
|
285
324
|
it("should filter by query", () => {
|
|
286
325
|
const handleClickMock = vi.fn();
|
|
287
326
|
const toggleModalMock = vi.fn() as CalledWithMock<void, []> & (() => void);
|
|
288
|
-
defaultProps.categories = [
|
|
289
|
-
{ featured: true, label: "All", value: "all" },
|
|
290
|
-
{ label: "Content", value: "content" },
|
|
291
|
-
{ label: "Collections", value: "collections" },
|
|
292
|
-
];
|
|
293
|
-
defaultProps.isOpen = true;
|
|
294
|
-
defaultProps.theme = "default-theme";
|
|
295
|
-
defaultProps.whiteList = ["BasicContent", "CardCollection"];
|
|
296
|
-
defaultProps.onClick = handleClickMock;
|
|
297
|
-
defaultProps.toggleModal = toggleModalMock;
|
|
298
|
-
defaultProps.optionsType = "modules";
|
|
299
|
-
defaultProps.showSearch = true;
|
|
300
327
|
|
|
301
328
|
render(
|
|
302
329
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
303
|
-
<SideModal
|
|
330
|
+
<SideModal
|
|
331
|
+
{...makeProps({
|
|
332
|
+
categories: [
|
|
333
|
+
{ featured: true, label: "All", value: "all" },
|
|
334
|
+
{ label: "Content", value: "content" },
|
|
335
|
+
{ label: "Collections", value: "collections" },
|
|
336
|
+
],
|
|
337
|
+
isOpen: true,
|
|
338
|
+
theme: "default-theme",
|
|
339
|
+
whiteList: ["BasicContent", "CardCollection"],
|
|
340
|
+
onClick: handleClickMock,
|
|
341
|
+
toggleModal: toggleModalMock,
|
|
342
|
+
optionsType: "modules",
|
|
343
|
+
showSearch: true,
|
|
344
|
+
})}
|
|
345
|
+
/>
|
|
304
346
|
</ThemeProvider>,
|
|
305
347
|
);
|
|
306
348
|
|
|
@@ -322,9 +364,11 @@ describe("SideModal component events", () => {
|
|
|
322
364
|
map[event] = callback;
|
|
323
365
|
});
|
|
324
366
|
|
|
367
|
+
const toggleModal = vi.fn();
|
|
368
|
+
|
|
325
369
|
render(
|
|
326
370
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
327
|
-
<SideModal {...
|
|
371
|
+
<SideModal {...makeProps({ toggleModal })} />
|
|
328
372
|
</ThemeProvider>,
|
|
329
373
|
);
|
|
330
374
|
|
|
@@ -332,7 +376,7 @@ describe("SideModal component events", () => {
|
|
|
332
376
|
target: document.body,
|
|
333
377
|
});
|
|
334
378
|
|
|
335
|
-
expect(
|
|
379
|
+
expect(toggleModal).toHaveBeenCalled();
|
|
336
380
|
});
|
|
337
381
|
|
|
338
382
|
it("should not call toggle modal on click inside the modal", () => {
|
|
@@ -342,9 +386,11 @@ describe("SideModal component events", () => {
|
|
|
342
386
|
map[event] = callback;
|
|
343
387
|
});
|
|
344
388
|
|
|
389
|
+
const toggleModal = vi.fn();
|
|
390
|
+
|
|
345
391
|
render(
|
|
346
392
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
347
|
-
<SideModal {...
|
|
393
|
+
<SideModal {...makeProps({ toggleModal })} />
|
|
348
394
|
</ThemeProvider>,
|
|
349
395
|
);
|
|
350
396
|
|
|
@@ -354,6 +400,6 @@ describe("SideModal component events", () => {
|
|
|
354
400
|
target: title,
|
|
355
401
|
});
|
|
356
402
|
|
|
357
|
-
expect(
|
|
403
|
+
expect(toggleModal).not.toHaveBeenCalled();
|
|
358
404
|
});
|
|
359
405
|
});
|