@griddo/ax 1.74.27 → 1.74.29
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.29",
|
|
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": "99bb983ffd06c3728640e8373d5a8615d530d92e"
|
|
233
233
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ThemeProvider } from "styled-components";
|
|
3
|
+
import { render, cleanup, screen } from "@testing-library/react";
|
|
4
|
+
import "@testing-library/jest-dom";
|
|
5
|
+
import { mock } from "jest-mock-extended";
|
|
6
|
+
|
|
7
|
+
import { parseTheme } from "@ax/helpers";
|
|
8
|
+
import Loader, { IStateProps } from "@ax/components/Loader";
|
|
9
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
10
|
+
|
|
11
|
+
afterEach(cleanup);
|
|
12
|
+
|
|
13
|
+
const defaultProps = mock<IStateProps>();
|
|
14
|
+
|
|
15
|
+
describe("Loader component rendering", () => {
|
|
16
|
+
it("should render the component with circle", () => {
|
|
17
|
+
defaultProps.name = "Circle.svg";
|
|
18
|
+
|
|
19
|
+
render(
|
|
20
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
21
|
+
<Loader {...defaultProps} />
|
|
22
|
+
</ThemeProvider>
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const wrapper = screen.getByTestId("circle-svg");
|
|
26
|
+
expect(wrapper).toBeTruthy();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("should render the component with dots", () => {
|
|
30
|
+
defaultProps.name = "Dots";
|
|
31
|
+
defaultProps.size = "60";
|
|
32
|
+
|
|
33
|
+
render(
|
|
34
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
35
|
+
<Loader {...defaultProps} />
|
|
36
|
+
</ThemeProvider>
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const wrapper = screen.getByTestId("dots-svg");
|
|
40
|
+
expect(wrapper).toBeTruthy();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("shouldn't render the component", () => {
|
|
44
|
+
defaultProps.name = "Dottsi-1.svg";
|
|
45
|
+
|
|
46
|
+
render(
|
|
47
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
48
|
+
<Loader {...defaultProps} />
|
|
49
|
+
</ThemeProvider>
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const circleWrapper = screen.queryByTestId("circle-svg");
|
|
53
|
+
const dotsWrapper = screen.queryByTestId("dots-svg");
|
|
54
|
+
expect(circleWrapper).not.toBeTruthy();
|
|
55
|
+
expect(dotsWrapper).not.toBeTruthy();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
|
|
3
3
|
function SvgCircle(props) {
|
|
4
4
|
return (
|
|
5
|
-
<svg viewBox="0 0 100 100" {...props}>
|
|
5
|
+
<svg data-testid="circle-svg" viewBox="0 0 100 100" {...props}>
|
|
6
6
|
<circle fill="none" stroke="#5057FF" strokeWidth={4} cx={50} cy={50} r={44} />
|
|
7
7
|
<circle fill="#fff" stroke="#5057FF" strokeWidth={3} cx={8} cy={54} r={6}>
|
|
8
8
|
<animateTransform attributeName="transform" dur="2s" type="rotate" from="0 50 48" to="360 50 52" repeatCount="indefinite" />
|
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
|
|
3
3
|
function SvgDots(props) {
|
|
4
4
|
return (
|
|
5
|
-
<svg viewBox="0 0 100 100" {...props}>
|
|
5
|
+
<svg data-testid="dots-svg" viewBox="0 0 100 100" {...props}>
|
|
6
6
|
<circle fill="#5057FF" cx={6} cy={50} r={6}>
|
|
7
7
|
<animate attributeName="opacity" dur="1s" values="0;1;0" repeatCount="indefinite" begin={0.1} />
|
|
8
8
|
</circle>
|
|
@@ -5,7 +5,15 @@ import Dots from "./components/Dots";
|
|
|
5
5
|
|
|
6
6
|
const components: Record<string, () => JSX.Element> = { Circle, Dots };
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const getImage = (name: string) => {
|
|
9
|
+
try {
|
|
10
|
+
return components[name];
|
|
11
|
+
} catch (err) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const Loader = (props: IProps): JSX.Element | null => {
|
|
9
17
|
const name = props.name
|
|
10
18
|
.replace(".svg", "")
|
|
11
19
|
.split("-")
|
|
@@ -13,20 +21,27 @@ const Loader = (props: IProps): JSX.Element => {
|
|
|
13
21
|
.join("");
|
|
14
22
|
|
|
15
23
|
const { size = "70" } = props;
|
|
24
|
+
|
|
16
25
|
const elementProps = {
|
|
17
26
|
height: size,
|
|
18
27
|
width: size,
|
|
19
28
|
viewBox: "0 0 100 100",
|
|
20
29
|
};
|
|
21
30
|
|
|
22
|
-
|
|
31
|
+
const Svg = getImage(name);
|
|
32
|
+
|
|
33
|
+
if (Svg) {
|
|
34
|
+
return React.createElement(Svg, elementProps);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return null;
|
|
23
38
|
};
|
|
24
39
|
|
|
25
|
-
interface IStateProps {
|
|
40
|
+
export interface IStateProps {
|
|
26
41
|
name: string;
|
|
27
42
|
size?: string;
|
|
28
43
|
}
|
|
29
44
|
|
|
30
45
|
type IProps = IStateProps;
|
|
31
46
|
|
|
32
|
-
export default Loader;
|
|
47
|
+
export default Loader;
|