@plurix/ecom-components 0.0.2-beta.8 → 0.0.2-beta.9
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/dist/packages/Onboarding/test/Bullets.test.js +20 -0
- package/dist/packages/Onboarding/test/Content.test.js +52 -0
- package/dist/packages/Onboarding/test/Footer.test.js +60 -0
- package/dist/packages/Onboarding/test/Header.test.js +30 -0
- package/dist/packages/Onboarding/test/Onboarding.test.js +22 -0
- package/dist/packages/Onboarding/test/SocialMedia.test.js +39 -0
- package/package.json +2 -2
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { render as s } from "@testing-library/react";
|
|
3
|
+
import "@testing-library/jest-dom";
|
|
4
|
+
import { Bullets as o } from "../components/Bullets.js";
|
|
5
|
+
jest.mock("../constants/tips", () => ({ TIPS_LENGTH: 3 }));
|
|
6
|
+
describe("Bullets component tests", () => {
|
|
7
|
+
it("renders correctly amount of bullets", () => {
|
|
8
|
+
const { container: t } = s(/* @__PURE__ */ l(o, { step: 1 })), e = t.querySelectorAll(".bullet");
|
|
9
|
+
expect(e.length).toBe(3);
|
|
10
|
+
}), it("should first bullet active if step is 1", () => {
|
|
11
|
+
const { container: t } = s(/* @__PURE__ */ l(o, { step: 1 })), e = t.querySelector(".bullet");
|
|
12
|
+
expect(e).toHaveClass("active");
|
|
13
|
+
}), it("should middle bullet active if step is greater than 1 and less than TIPS_LENGTH", () => {
|
|
14
|
+
const { container: t } = s(/* @__PURE__ */ l(o, { step: 2 })), e = t.querySelector(".bullet:nth-child(2)");
|
|
15
|
+
expect(e).toHaveClass("active");
|
|
16
|
+
}), it("should last bullet active if step is equal than TIPS_LENGTH", () => {
|
|
17
|
+
const { container: t } = s(/* @__PURE__ */ l(o, { step: 3 })), e = t.querySelector(".bullet:last-child");
|
|
18
|
+
expect(e).toHaveClass("active");
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { render as s } from "@testing-library/react";
|
|
3
|
+
import "@testing-library/jest-dom";
|
|
4
|
+
import { Content as o } from "../components/Content.js";
|
|
5
|
+
jest.mock("../components/SocialMedia", () => ({
|
|
6
|
+
SocialMedia: () => /* @__PURE__ */ e("div", { "data-testid": "social media" })
|
|
7
|
+
}));
|
|
8
|
+
jest.mock("../constants/tips", () => ({
|
|
9
|
+
TIPS_LENGTH: 2,
|
|
10
|
+
TIPS: [
|
|
11
|
+
{
|
|
12
|
+
tip: "tip 1",
|
|
13
|
+
svg: () => /* @__PURE__ */ e("div", { "data-testid": "svg 1" }),
|
|
14
|
+
isIllustration: !1
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
tip: "tip 2",
|
|
18
|
+
svg: () => /* @__PURE__ */ e("div", { "data-testid": "svg 2" }),
|
|
19
|
+
isIllustration: !0
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}));
|
|
23
|
+
const n = jest.fn();
|
|
24
|
+
describe("Content component tests", () => {
|
|
25
|
+
it("should render nothing if step is invalid", () => {
|
|
26
|
+
const { container: t } = s(/* @__PURE__ */ e(o, { step: 0, sendEvent: n }));
|
|
27
|
+
expect(t.firstChild).toBeNull();
|
|
28
|
+
}), it("should render correctly texts", () => {
|
|
29
|
+
const { getByTestId: t, getByText: i } = s(
|
|
30
|
+
/* @__PURE__ */ e(o, { step: 1, sendEvent: n })
|
|
31
|
+
);
|
|
32
|
+
expect(t("svg 1")).toBeInTheDocument(), expect(i("1 de 2")).toBeInTheDocument(), expect(i("tip 1")).toBeInTheDocument();
|
|
33
|
+
}), it("should render correctly illustration message", () => {
|
|
34
|
+
const { getByText: t } = s(/* @__PURE__ */ e(o, { step: 2, sendEvent: n }));
|
|
35
|
+
expect(t("Imagem Ilustrativa")).toBeInTheDocument();
|
|
36
|
+
}), it("should render correctly social media section", () => {
|
|
37
|
+
const { getByTestId: t } = s(
|
|
38
|
+
/* @__PURE__ */ e(
|
|
39
|
+
o,
|
|
40
|
+
{
|
|
41
|
+
step: 2,
|
|
42
|
+
socialMediaLinks: {
|
|
43
|
+
facebook: "facebook_link",
|
|
44
|
+
instagram: "instagram_link"
|
|
45
|
+
},
|
|
46
|
+
sendEvent: n
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
);
|
|
50
|
+
expect(t("social media")).toBeInTheDocument();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { render as c, fireEvent as a } from "@testing-library/react";
|
|
3
|
+
import "@testing-library/jest-dom";
|
|
4
|
+
import { Footer as l } from "../components/Footer.js";
|
|
5
|
+
jest.mock("../constants/tips", () => ({ TIPS_LENGTH: 3 }));
|
|
6
|
+
jest.mock("../components/Bullets", () => ({
|
|
7
|
+
Bullets: () => /* @__PURE__ */ n("div", { "data-testid": "bullets" })
|
|
8
|
+
}));
|
|
9
|
+
const t = jest.fn(), o = jest.fn();
|
|
10
|
+
describe("Footer component tests", () => {
|
|
11
|
+
it("renders default UI", () => {
|
|
12
|
+
const { getByText: e } = c(
|
|
13
|
+
/* @__PURE__ */ n(
|
|
14
|
+
l,
|
|
15
|
+
{
|
|
16
|
+
step: 1,
|
|
17
|
+
handleBackStep: t,
|
|
18
|
+
handleNextStep: o
|
|
19
|
+
}
|
|
20
|
+
)
|
|
21
|
+
);
|
|
22
|
+
expect(e("Voltar")).toBeInTheDocument(), expect(e("Próximo")).toBeInTheDocument();
|
|
23
|
+
}), it("renders correctly button text if step is equal than TIPS_LENGTH", () => {
|
|
24
|
+
const { queryByText: e, getByText: s } = c(
|
|
25
|
+
/* @__PURE__ */ n(
|
|
26
|
+
l,
|
|
27
|
+
{
|
|
28
|
+
step: 3,
|
|
29
|
+
handleBackStep: t,
|
|
30
|
+
handleNextStep: o
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
);
|
|
34
|
+
expect(e("Próximo")).not.toBeInTheDocument(), expect(s("Legal, Entendi")).toBeInTheDocument();
|
|
35
|
+
}), it("should call handleBackStep on click back button", () => {
|
|
36
|
+
const { getByText: e } = c(
|
|
37
|
+
/* @__PURE__ */ n(
|
|
38
|
+
l,
|
|
39
|
+
{
|
|
40
|
+
step: 1,
|
|
41
|
+
handleBackStep: t,
|
|
42
|
+
handleNextStep: o
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
);
|
|
46
|
+
a.click(e("Voltar")), expect(t).toHaveBeenCalled();
|
|
47
|
+
}), it("should call handleNextStep on click confirm button", () => {
|
|
48
|
+
const { getByText: e } = c(
|
|
49
|
+
/* @__PURE__ */ n(
|
|
50
|
+
l,
|
|
51
|
+
{
|
|
52
|
+
step: 1,
|
|
53
|
+
handleBackStep: t,
|
|
54
|
+
handleNextStep: o
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
);
|
|
58
|
+
a.click(e("Próximo")), expect(o).toHaveBeenCalled();
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { render as c, fireEvent as d } from "@testing-library/react";
|
|
3
|
+
import "@testing-library/jest-dom";
|
|
4
|
+
import { Header as s } from "../components/Header.js";
|
|
5
|
+
const t = jest.fn(), n = jest.fn();
|
|
6
|
+
describe("Header component tests", () => {
|
|
7
|
+
it("renders correctly UI", () => {
|
|
8
|
+
const { getByText: e, getByTestId: l } = c(
|
|
9
|
+
/* @__PURE__ */ o(
|
|
10
|
+
s,
|
|
11
|
+
{
|
|
12
|
+
sendEvent: t,
|
|
13
|
+
handleCloseAction: n
|
|
14
|
+
}
|
|
15
|
+
)
|
|
16
|
+
);
|
|
17
|
+
expect(e("Experiência Personalizada")).toBeInTheDocument(), expect(l("close-icon")).toBeInTheDocument();
|
|
18
|
+
}), it("should call sendEvent and handleCloseAction on click close button", () => {
|
|
19
|
+
const { getByTestId: e } = c(
|
|
20
|
+
/* @__PURE__ */ o(
|
|
21
|
+
s,
|
|
22
|
+
{
|
|
23
|
+
sendEvent: t,
|
|
24
|
+
handleCloseAction: n
|
|
25
|
+
}
|
|
26
|
+
)
|
|
27
|
+
);
|
|
28
|
+
d.click(e("close-icon")), expect(t).toHaveBeenCalled(), expect(n).toHaveBeenCalled();
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { render as o } from "@testing-library/react";
|
|
3
|
+
import "@testing-library/jest-dom";
|
|
4
|
+
import { Onboarding as n } from "../Onboarding.js";
|
|
5
|
+
jest.mock("../components/Header", () => ({
|
|
6
|
+
Header: () => /* @__PURE__ */ e("div", { "data-testid": "header" })
|
|
7
|
+
}));
|
|
8
|
+
jest.mock("../components/Content", () => ({
|
|
9
|
+
Content: () => /* @__PURE__ */ e("div", { "data-testid": "content" })
|
|
10
|
+
}));
|
|
11
|
+
jest.mock("../components/Footer", () => ({
|
|
12
|
+
Footer: () => /* @__PURE__ */ e("div", { "data-testid": "footer" })
|
|
13
|
+
}));
|
|
14
|
+
const c = jest.fn();
|
|
15
|
+
describe("Onboarding package tests", () => {
|
|
16
|
+
it("should render sections correctly", () => {
|
|
17
|
+
const { getByTestId: t } = o(
|
|
18
|
+
/* @__PURE__ */ e(n, { handleCloseAction: c })
|
|
19
|
+
);
|
|
20
|
+
expect(t("header")).toBeInTheDocument(), expect(t("content")).toBeInTheDocument(), expect(t("footer")).toBeInTheDocument();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { render as n, fireEvent as c } from "@testing-library/react";
|
|
3
|
+
import "@testing-library/jest-dom";
|
|
4
|
+
import { SocialMedia as t } from "../components/SocialMedia.js";
|
|
5
|
+
const o = jest.fn();
|
|
6
|
+
describe("SocialMedia component tests", () => {
|
|
7
|
+
it("should render nothing if socialMediaLinks does not exist", () => {
|
|
8
|
+
const { container: e } = n(/* @__PURE__ */ i(t, { sendEvent: o }));
|
|
9
|
+
expect(e.firstChild).toBeNull();
|
|
10
|
+
}), it("should render media section if link exist", () => {
|
|
11
|
+
const { getByTestId: e } = n(
|
|
12
|
+
/* @__PURE__ */ i(
|
|
13
|
+
t,
|
|
14
|
+
{
|
|
15
|
+
socialMediaLinks: {
|
|
16
|
+
facebook: "facebook_link",
|
|
17
|
+
instagram: "instagram_link"
|
|
18
|
+
},
|
|
19
|
+
sendEvent: o
|
|
20
|
+
}
|
|
21
|
+
)
|
|
22
|
+
);
|
|
23
|
+
expect(e("facebook-icon")).toBeInTheDocument(), expect(e("instagram-icon")).toBeInTheDocument();
|
|
24
|
+
}), it("should call sendEvent on click social media link", () => {
|
|
25
|
+
const { getByTestId: e } = n(
|
|
26
|
+
/* @__PURE__ */ i(
|
|
27
|
+
t,
|
|
28
|
+
{
|
|
29
|
+
socialMediaLinks: {
|
|
30
|
+
facebook: "facebook_link",
|
|
31
|
+
instagram: "instagram_link"
|
|
32
|
+
},
|
|
33
|
+
sendEvent: o
|
|
34
|
+
}
|
|
35
|
+
)
|
|
36
|
+
);
|
|
37
|
+
c.click(e("facebook-icon")), expect(o).toHaveBeenCalledWith("facebook");
|
|
38
|
+
});
|
|
39
|
+
});
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@plurix/ecom-components",
|
|
3
3
|
"author": "Plurix",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.0.2-beta.
|
|
5
|
+
"version": "0.0.2-beta.9",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/main.js",
|
|
8
8
|
"types": "dist/main.d.ts",
|
|
@@ -53,6 +53,6 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@acctglobal/skeleton": "^1.0.0",
|
|
56
|
-
"axios": "1.
|
|
56
|
+
"axios": "^1.5.1"
|
|
57
57
|
}
|
|
58
58
|
}
|