@griddo/ax 1.75.7 → 1.75.8
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": "@griddo/ax",
|
|
3
3
|
"description": "Griddo Author Experience",
|
|
4
|
-
"version": "1.75.
|
|
4
|
+
"version": "1.75.8",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Carlos Torres <carlos.torres@secuoyas.com>",
|
|
@@ -229,5 +229,5 @@
|
|
|
229
229
|
"publishConfig": {
|
|
230
230
|
"access": "public"
|
|
231
231
|
},
|
|
232
|
-
"gitHead": "
|
|
232
|
+
"gitHead": "172d6f9cd5092a354f09cdcb60ec1159e3469920"
|
|
233
233
|
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { ThemeProvider } from "styled-components";
|
|
4
|
+
import { render, cleanup, screen, fireEvent } from "@testing-library/react";
|
|
5
|
+
import { mock } from "jest-mock-extended";
|
|
6
|
+
import "@testing-library/jest-dom";
|
|
7
|
+
|
|
8
|
+
import { parseTheme } from "@ax/helpers";
|
|
9
|
+
import Breadcrumb, { IBreadcrumbProps } from "@ax/components/Breadcrumb";
|
|
10
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
11
|
+
|
|
12
|
+
afterEach(cleanup);
|
|
13
|
+
|
|
14
|
+
const defaultProps = mock<IBreadcrumbProps>();
|
|
15
|
+
|
|
16
|
+
describe("Breadcrumb component rendering", () => {
|
|
17
|
+
it("should render the component", () => {
|
|
18
|
+
const breadcrumbItemMock = [
|
|
19
|
+
{
|
|
20
|
+
editorID: 1,
|
|
21
|
+
component: "MenuItem",
|
|
22
|
+
displayName: "Menu 1",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
editorID: 2,
|
|
26
|
+
component: "MenuItem",
|
|
27
|
+
displayName: "Menu 2",
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
defaultProps.breadcrumb = breadcrumbItemMock;
|
|
32
|
+
|
|
33
|
+
render(
|
|
34
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
35
|
+
<Breadcrumb {...defaultProps} />
|
|
36
|
+
</ThemeProvider>
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const breadcrumbWrapper = screen.getByTestId("breadcrumb-group-wrapper");
|
|
40
|
+
expect(breadcrumbWrapper).toBeTruthy();
|
|
41
|
+
const breadcrumbItems = screen.getAllByTestId("breadcrumb-item");
|
|
42
|
+
expect(breadcrumbItems).toHaveLength(2);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("should render only the menuItem", () => {
|
|
46
|
+
const breadcrumbItemMock = [
|
|
47
|
+
{
|
|
48
|
+
editorID: 1,
|
|
49
|
+
component: "MenuItem",
|
|
50
|
+
displayName: "Menu 1",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
editorID: 2,
|
|
54
|
+
component: "Section",
|
|
55
|
+
displayName: "Menu 2",
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
defaultProps.breadcrumb = breadcrumbItemMock;
|
|
60
|
+
|
|
61
|
+
render(
|
|
62
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
63
|
+
<Breadcrumb {...defaultProps} />
|
|
64
|
+
</ThemeProvider>
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const breadcrumbItems = screen.getAllByTestId("breadcrumb-item");
|
|
68
|
+
expect(breadcrumbItems).toHaveLength(1);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("should handle the onclick", () => {
|
|
72
|
+
const breadcrumbItemMock = [
|
|
73
|
+
{
|
|
74
|
+
editorID: 1,
|
|
75
|
+
component: "MenuItem",
|
|
76
|
+
displayName: "Menu 1",
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
editorID: 2,
|
|
80
|
+
component: "Section",
|
|
81
|
+
displayName: "Menu 2",
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
|
|
85
|
+
defaultProps.breadcrumb = breadcrumbItemMock;
|
|
86
|
+
const setSelectedContentMock = jest.fn();
|
|
87
|
+
defaultProps.setSelectedContent = setSelectedContentMock;
|
|
88
|
+
|
|
89
|
+
render(
|
|
90
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
91
|
+
<Breadcrumb {...defaultProps} />
|
|
92
|
+
</ThemeProvider>
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const breadcrumbItems = screen.getAllByTestId("breadcrumb-item");
|
|
96
|
+
expect(breadcrumbItems).toHaveLength(1);
|
|
97
|
+
fireEvent.click(breadcrumbItems[0]);
|
|
98
|
+
expect(setSelectedContentMock).toBeCalled();
|
|
99
|
+
});
|
|
100
|
+
});
|
|
@@ -10,7 +10,7 @@ const Breadcrumb = ({ breadcrumb, setSelectedContent }: IBreadcrumbProps): JSX.E
|
|
|
10
10
|
const isPageSection = (i: number, component: string) => i === 1 && component === "Section";
|
|
11
11
|
|
|
12
12
|
return (
|
|
13
|
-
<S.BreadcrumbGroup>
|
|
13
|
+
<S.BreadcrumbGroup data-testid="breadcrumb-group-wrapper">
|
|
14
14
|
{!isRoot &&
|
|
15
15
|
breadcrumb.slice(0).map((item: IBreadcrumbItem, index: number, arr: any) => {
|
|
16
16
|
const { editorID, component, displayName } = item;
|
|
@@ -20,7 +20,7 @@ const Breadcrumb = ({ breadcrumb, setSelectedContent }: IBreadcrumbProps): JSX.E
|
|
|
20
20
|
|
|
21
21
|
return isPageSection(index, component) ? null : (
|
|
22
22
|
<React.Fragment key={`${editorID}${index}`}>
|
|
23
|
-
<S.BreadcrumbItem onClick={handleClick} isLastItem={isLastItem}>
|
|
23
|
+
<S.BreadcrumbItem data-testid="breadcrumb-item" onClick={handleClick} isLastItem={isLastItem}>
|
|
24
24
|
{displayName}
|
|
25
25
|
</S.BreadcrumbItem>
|
|
26
26
|
{index <= arr.length - 2 && (
|
|
@@ -35,7 +35,7 @@ const Breadcrumb = ({ breadcrumb, setSelectedContent }: IBreadcrumbProps): JSX.E
|
|
|
35
35
|
);
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
interface IBreadcrumbProps {
|
|
38
|
+
export interface IBreadcrumbProps {
|
|
39
39
|
breadcrumb: IBreadcrumbItem[];
|
|
40
40
|
setSelectedContent: any;
|
|
41
41
|
}
|