@griddo/ax 1.75.34 → 1.75.36
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.36",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Carlos Torres <carlos.torres@secuoyas.com>",
|
|
@@ -230,5 +230,5 @@
|
|
|
230
230
|
"publishConfig": {
|
|
231
231
|
"access": "public"
|
|
232
232
|
},
|
|
233
|
-
"gitHead": "
|
|
233
|
+
"gitHead": "2d221923450bac0e467a2f6b3c30db8b29a9f5f0"
|
|
234
234
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
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 CategoryCell, { ICategoryCellProps } from "@ax/components/CategoryCell";
|
|
10
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
11
|
+
|
|
12
|
+
afterEach(cleanup);
|
|
13
|
+
|
|
14
|
+
const defaultProps = mock<ICategoryCellProps>();
|
|
15
|
+
const addCategoryColorsMock = defaultProps.addCategoryColors as jest.MockedFunction<(cats: string[]) => void>;
|
|
16
|
+
|
|
17
|
+
describe("CategoryCell component rendering", () => {
|
|
18
|
+
it("should render the component with no elements", () => {
|
|
19
|
+
defaultProps.categoryColors = {};
|
|
20
|
+
defaultProps.categories = false;
|
|
21
|
+
|
|
22
|
+
render(
|
|
23
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
24
|
+
<CategoryCell {...defaultProps} />
|
|
25
|
+
</ThemeProvider>
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
expect(screen.queryByTestId("elements-wrapper")).not.toBeTruthy();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("should render the component with one element and no remaining element", () => {
|
|
32
|
+
defaultProps.categoryColors = {
|
|
33
|
+
Hogwarts: "#FFE695",
|
|
34
|
+
};
|
|
35
|
+
defaultProps.categories = ["Hogwarts"];
|
|
36
|
+
|
|
37
|
+
render(
|
|
38
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
39
|
+
<CategoryCell {...defaultProps} />
|
|
40
|
+
</ThemeProvider>
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
expect(addCategoryColorsMock).toBeCalled();
|
|
44
|
+
expect(screen.getByTestId("elements-wrapper")).toBeTruthy();
|
|
45
|
+
expect(screen.queryByTestId("remaining-element")).not.toBeTruthy();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("should render the component with two remaining elements", () => {
|
|
49
|
+
defaultProps.categoryColors = {
|
|
50
|
+
Hogwarts: "#FFE695",
|
|
51
|
+
Test: "#FFE695",
|
|
52
|
+
};
|
|
53
|
+
defaultProps.categories = ["Hogwarts", "Test"];
|
|
54
|
+
|
|
55
|
+
render(
|
|
56
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
57
|
+
<CategoryCell {...defaultProps} />
|
|
58
|
+
</ThemeProvider>
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
expect(addCategoryColorsMock).toBeCalled();
|
|
62
|
+
expect(screen.getByTestId("elements-wrapper")).toBeTruthy();
|
|
63
|
+
expect(screen.getByTestId("remaining-element")).toBeTruthy();
|
|
64
|
+
expect(screen.getAllByTestId("div-element")).toHaveLength(2);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { useEffect } from "react";
|
|
2
2
|
import { ElementsTooltip } from "@ax/components";
|
|
3
|
-
import * as S from "./style"
|
|
3
|
+
import * as S from "./style";
|
|
4
4
|
|
|
5
|
-
const CategoryCell = (props:
|
|
5
|
+
const CategoryCell = (props: ICategoryCellProps): JSX.Element => {
|
|
6
6
|
const { categories, categoryColors, addCategoryColors } = props;
|
|
7
7
|
|
|
8
8
|
useEffect(() => {
|
|
@@ -17,7 +17,7 @@ const CategoryCell = (props: IProps): JSX.Element => {
|
|
|
17
17
|
);
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
interface
|
|
20
|
+
export interface ICategoryCellProps {
|
|
21
21
|
categories: any;
|
|
22
22
|
categoryColors: any;
|
|
23
23
|
addCategoryColors(cats: string[]): void;
|