@griddo/ax 1.74.33 → 1.74.35
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.74.
|
|
4
|
+
"version": "1.74.35",
|
|
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": "c8d0bc0b49e530a1ee13bf6ad5c473c474e7884c"
|
|
233
233
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ThemeProvider } from "styled-components";
|
|
3
|
+
import { render, cleanup, screen } from "@testing-library/react";
|
|
4
|
+
import { mock } from "jest-mock-extended";
|
|
5
|
+
import "@testing-library/jest-dom";
|
|
6
|
+
|
|
7
|
+
import { parseTheme } from "@ax/helpers";
|
|
8
|
+
import Image, { IImageProps } from "@ax/components/Image";
|
|
9
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
10
|
+
|
|
11
|
+
afterEach(cleanup);
|
|
12
|
+
|
|
13
|
+
const defaultProps = mock<IImageProps>();
|
|
14
|
+
|
|
15
|
+
describe("Image component rendering", () => {
|
|
16
|
+
it("should render the component with img tag", () => {
|
|
17
|
+
defaultProps.width = 1;
|
|
18
|
+
defaultProps.url = "https://res.cloudinary.com/url-example.png";
|
|
19
|
+
|
|
20
|
+
render(
|
|
21
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
22
|
+
<Image {...defaultProps} />
|
|
23
|
+
</ThemeProvider>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const imageWrapper = screen.getByTestId("image-wrapper");
|
|
27
|
+
expect(imageWrapper).toBeTruthy();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("should render the component griddoImage", () => {
|
|
31
|
+
defaultProps.width = 1;
|
|
32
|
+
defaultProps.url = "/url-example.png";
|
|
33
|
+
|
|
34
|
+
render(
|
|
35
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
36
|
+
<Image {...defaultProps} />
|
|
37
|
+
</ThemeProvider>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const imageWrapper = screen.queryByTestId("image-wrapper");
|
|
41
|
+
expect(imageWrapper).not.toBeTruthy();
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ThemeProvider } from "styled-components";
|
|
3
|
+
import { render, cleanup, screen, fireEvent } from "@testing-library/react";
|
|
4
|
+
import "@testing-library/jest-dom";
|
|
5
|
+
|
|
6
|
+
import { parseTheme } from "@ax/helpers";
|
|
7
|
+
import { ListItem, ListItemProps } from "@ax/components/Lists";
|
|
8
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
9
|
+
|
|
10
|
+
afterEach(cleanup);
|
|
11
|
+
|
|
12
|
+
const onClickMock = jest.fn();
|
|
13
|
+
|
|
14
|
+
const defaultProps: ListItemProps = {
|
|
15
|
+
children: false,
|
|
16
|
+
onClick: onClickMock,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
describe("List component rendering", () => {
|
|
20
|
+
it("should render the component with icon", () => {
|
|
21
|
+
defaultProps.isSelected = true;
|
|
22
|
+
|
|
23
|
+
render(
|
|
24
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
25
|
+
<ListItem {...defaultProps} />
|
|
26
|
+
</ThemeProvider>
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const wrapperList = screen.getByTestId("list-item");
|
|
30
|
+
expect(wrapperList).toBeTruthy();
|
|
31
|
+
|
|
32
|
+
const icon = screen.getByTestId("icon-component");
|
|
33
|
+
expect(icon).toBeTruthy();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("should render the component with no icon", () => {
|
|
37
|
+
defaultProps.isSelected = false;
|
|
38
|
+
|
|
39
|
+
render(
|
|
40
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
41
|
+
<ListItem {...defaultProps} />
|
|
42
|
+
</ThemeProvider>
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const wrapperList = screen.getByTestId("list-item");
|
|
46
|
+
expect(wrapperList).toBeTruthy();
|
|
47
|
+
|
|
48
|
+
const icon = screen.queryByTestId("icon-component");
|
|
49
|
+
expect(icon).not.toBeTruthy();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("should call the onclick", () => {
|
|
53
|
+
defaultProps.isSelected = false;
|
|
54
|
+
|
|
55
|
+
render(
|
|
56
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
57
|
+
<ListItem {...defaultProps} />
|
|
58
|
+
</ThemeProvider>
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const wrapperList = screen.getByTestId("list-item");
|
|
62
|
+
expect(wrapperList).toBeTruthy();
|
|
63
|
+
|
|
64
|
+
const icon = screen.queryByTestId("icon-component");
|
|
65
|
+
expect(icon).not.toBeTruthy();
|
|
66
|
+
|
|
67
|
+
fireEvent.click(wrapperList);
|
|
68
|
+
expect(onClickMock).toBeCalled();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
@@ -9,18 +9,18 @@ const DAM_DEFAULTS = {
|
|
|
9
9
|
formats: ["webp"],
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
const Image = (props:
|
|
12
|
+
const Image = (props: IImageProps): React.ReactElement => {
|
|
13
13
|
const { url } = props;
|
|
14
14
|
|
|
15
15
|
if (isCloudinary(url)) {
|
|
16
16
|
const cloudinaryUrl = createCloudinaryUrl({ props });
|
|
17
|
-
return <img src={cloudinaryUrl} alt="Griddo site thumbnail" />;
|
|
17
|
+
return <img data-testid="image-wrapper" src={cloudinaryUrl} alt="Griddo site thumbnail" />;
|
|
18
18
|
} else {
|
|
19
19
|
return <GriddoImage {...DAM_DEFAULTS} {...props} />;
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
export interface
|
|
23
|
+
export interface IImageProps {
|
|
24
24
|
width: number;
|
|
25
25
|
height?: number;
|
|
26
26
|
url: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IImageProps } from "./index";
|
|
2
2
|
|
|
3
3
|
// The string to split up the cloudinary url
|
|
4
4
|
const CLOUDINARY_SEPARATOR = "image/upload";
|
|
@@ -48,7 +48,7 @@ interface ICloudinaryParams {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
interface ICreateCloudinaryUrl {
|
|
51
|
-
props:
|
|
51
|
+
props: IImageProps;
|
|
52
52
|
retina?: boolean;
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -11,16 +11,13 @@ const ListItem = (props: ListItemProps): JSX.Element => {
|
|
|
11
11
|
{children}
|
|
12
12
|
{isSelected && <Icon name="Done" size="16" />}
|
|
13
13
|
</S.StyledListItem>
|
|
14
|
-
)
|
|
15
|
-
}
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
16
|
|
|
17
|
-
interface ListItemProps {
|
|
17
|
+
export interface ListItemProps {
|
|
18
18
|
isSelected?: boolean;
|
|
19
19
|
children: React.ReactNode;
|
|
20
20
|
onClick: React.MouseEventHandler<HTMLSpanElement>;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export {
|
|
24
|
-
ListTitle,
|
|
25
|
-
ListItem
|
|
26
|
-
}
|
|
23
|
+
export { ListTitle, ListItem };
|