zebpay-ui 0.0.41 → 0.0.43
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/.vscode/settings.json +3 -0
- package/coverage/clover.xml +424 -0
- package/coverage/coverage-final.json +23 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/components/Accordion/index.html +131 -0
- package/coverage/lcov-report/components/Accordion/index.tsx.html +202 -0
- package/coverage/lcov-report/components/Accordion/style.ts.html +166 -0
- package/coverage/lcov-report/components/Button/index.html +131 -0
- package/coverage/lcov-report/components/Button/index.tsx.html +277 -0
- package/coverage/lcov-report/components/Button/styles.ts.html +532 -0
- package/coverage/lcov-report/components/CircularLoader/index.html +131 -0
- package/coverage/lcov-report/components/CircularLoader/index.tsx.html +286 -0
- package/coverage/lcov-report/components/CircularLoader/style.ts.html +148 -0
- package/coverage/lcov-report/components/Input/index.html +131 -0
- package/coverage/lcov-report/components/Input/index.tsx.html +409 -0
- package/coverage/lcov-report/components/Input/styles.ts.html +433 -0
- package/coverage/lcov-report/components/PinInput/PinInputField.tsx.html +517 -0
- package/coverage/lcov-report/components/PinInput/index.html +146 -0
- package/coverage/lcov-report/components/PinInput/index.tsx.html +268 -0
- package/coverage/lcov-report/components/PinInput/style.ts.html +247 -0
- package/coverage/lcov-report/components/Popper/index.html +131 -0
- package/coverage/lcov-report/components/Popper/index.tsx.html +346 -0
- package/coverage/lcov-report/components/Popper/styles.ts.html +205 -0
- package/coverage/lcov-report/components/SidePanel/index.html +131 -0
- package/coverage/lcov-report/components/SidePanel/index.tsx.html +343 -0
- package/coverage/lcov-report/components/SidePanel/style.ts.html +307 -0
- package/coverage/lcov-report/components/Tooltip/index.html +131 -0
- package/coverage/lcov-report/components/Tooltip/index.tsx.html +307 -0
- package/coverage/lcov-report/components/Tooltip/styles.ts.html +157 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +236 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/styles/colors.ts.html +235 -0
- package/coverage/lcov-report/styles/index.html +176 -0
- package/coverage/lcov-report/styles/index.ts.html +103 -0
- package/coverage/lcov-report/styles/mixins.ts.html +355 -0
- package/coverage/lcov-report/styles/typography.ts.html +1105 -0
- package/coverage/lcov-report/styles/utils.ts.html +202 -0
- package/coverage/lcov.info +780 -0
- package/dist/cjs/components/Avatar/index.d.ts +5 -0
- package/dist/cjs/components/Avatar/styles.d.ts +4 -0
- package/dist/cjs/components/Avatar/typings.d.ts +19 -0
- package/dist/cjs/components/AvatarGroup/index.d.ts +5 -0
- package/dist/cjs/components/AvatarGroup/styles.d.ts +1 -0
- package/dist/cjs/components/AvatarGroup/typings.d.ts +19 -0
- package/dist/cjs/components/RewardOMeter/index.d.ts +5 -0
- package/dist/cjs/components/RewardOMeter/styles.d.ts +3 -0
- package/dist/cjs/components/RewardOMeter/typings.d.ts +22 -0
- package/dist/cjs/components/index.d.ts +4 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/styles/colors.d.ts +5 -0
- package/dist/esm/components/Avatar/index.d.ts +5 -0
- package/dist/esm/components/Avatar/styles.d.ts +4 -0
- package/dist/esm/components/Avatar/typings.d.ts +19 -0
- package/dist/esm/components/AvatarGroup/index.d.ts +5 -0
- package/dist/esm/components/AvatarGroup/styles.d.ts +1 -0
- package/dist/esm/components/AvatarGroup/typings.d.ts +19 -0
- package/dist/esm/components/RewardOMeter/index.d.ts +5 -0
- package/dist/esm/components/RewardOMeter/styles.d.ts +3 -0
- package/dist/esm/components/RewardOMeter/typings.d.ts +22 -0
- package/dist/esm/components/index.d.ts +4 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/styles/colors.d.ts +5 -0
- package/dist/icons/icons.css +191 -185
- package/dist/icons/icons.eot +0 -0
- package/dist/icons/icons.html +18 -0
- package/dist/icons/icons.json +184 -182
- package/dist/icons/icons.ts +190 -182
- package/dist/icons/icons.woff +0 -0
- package/dist/icons/icons.woff2 +0 -0
- package/jest.config.js +15 -0
- package/package.json +21 -6
- package/tests/Accordion.test.tsx +40 -0
- package/tests/Avatar.test.tsx +76 -0
- package/tests/Button.test.tsx +35 -0
- package/tests/Input.test.tsx +39 -0
- package/tests/PinInput.test.tsx +89 -0
- package/tests/Popper.test.tsx +50 -0
- package/tests/RewardOMeter.test.tsx +73 -0
- package/tests/SearchInput.test.tsx +34 -0
- package/tests/Select.test.tsx +74 -0
- package/tests/SidePanel.test.tsx +74 -0
- package/tests/Tooltip.test.tsx +36 -0
- package/tests/__snapshots__/Accordion.test.tsx.snap +11 -0
- package/tests/__snapshots__/Button.test.tsx.snap +10 -0
- package/tests/__snapshots__/PinInput.test.tsx.snap +18 -0
- package/tests/__snapshots__/Popper.test.tsx.snap +15 -0
- package/tests/__snapshots__/SidePanel.test.tsx.snap +10 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import Button from "../src/components/Button";
|
|
3
|
+
import { render, fireEvent, cleanup, screen } from "@testing-library/react";
|
|
4
|
+
|
|
5
|
+
afterEach(cleanup);
|
|
6
|
+
|
|
7
|
+
const defaultProps = {
|
|
8
|
+
onClick: jest.fn(),
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
describe("Button Test", () => {
|
|
12
|
+
it("is rendered correctly", () => {
|
|
13
|
+
render(
|
|
14
|
+
<Button type="link" {...defaultProps}>
|
|
15
|
+
Click Me!
|
|
16
|
+
</Button>
|
|
17
|
+
);
|
|
18
|
+
expect(
|
|
19
|
+
<Button type="link" {...defaultProps}>
|
|
20
|
+
Click Me!
|
|
21
|
+
</Button>
|
|
22
|
+
).toMatchSnapshot();
|
|
23
|
+
});
|
|
24
|
+
test("is clicked", () => {
|
|
25
|
+
const handleClick = jest.fn();
|
|
26
|
+
render(
|
|
27
|
+
<Button type="link" onClick={handleClick}>
|
|
28
|
+
Click Me!
|
|
29
|
+
</Button>
|
|
30
|
+
);
|
|
31
|
+
const button = screen.getByTestId("button");
|
|
32
|
+
fireEvent.click(button);
|
|
33
|
+
expect(handleClick).toHaveBeenCalledTimes(1);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import Input from "../src/components/Input";
|
|
3
|
+
import { render, fireEvent, cleanup, screen } from "@testing-library/react";
|
|
4
|
+
import userEvent from "@testing-library/user-event";
|
|
5
|
+
|
|
6
|
+
afterEach(cleanup);
|
|
7
|
+
|
|
8
|
+
const defaultProps = {
|
|
9
|
+
label: "Testing Input",
|
|
10
|
+
placeholder: "Placeholder",
|
|
11
|
+
value: "Default",
|
|
12
|
+
onChange: () => {},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
describe("Input Test", () => {
|
|
16
|
+
// it("is rendered correctly", () => {
|
|
17
|
+
// render(<Input {...defaultProps} />);
|
|
18
|
+
// expect(<Input {...defaultProps} />).toMatchSnapshot();
|
|
19
|
+
// });
|
|
20
|
+
|
|
21
|
+
test("is clicked", () => {
|
|
22
|
+
const handleChange = jest.fn();
|
|
23
|
+
|
|
24
|
+
render(<Input {...defaultProps} />);
|
|
25
|
+
const input = screen.getByTestId("input");
|
|
26
|
+
|
|
27
|
+
// expect(screen.getByText("Placeholder")).toBeInTheDocument();
|
|
28
|
+
|
|
29
|
+
fireEvent.change(screen.getByPlaceholderText("Placeholder"), {
|
|
30
|
+
target: { value: "updated" },
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// expect(input).toBeInTheDocument();
|
|
34
|
+
expect(screen.getByPlaceholderText("Placeholder")).toHaveValue("Default");
|
|
35
|
+
|
|
36
|
+
// fireEvent.click(input);
|
|
37
|
+
// expect(handleChange).toHaveBeenCalledTimes(1);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import PinInput from "../src/components/PinInput";
|
|
3
|
+
import { render, fireEvent, cleanup, screen } from "@testing-library/react";
|
|
4
|
+
|
|
5
|
+
afterEach(cleanup);
|
|
6
|
+
|
|
7
|
+
const defaultProps = {
|
|
8
|
+
length: 6,
|
|
9
|
+
label: "PinTest",
|
|
10
|
+
values: ["1", "1", "1", "1", "1", "1"],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
describe("PinInput", () => {
|
|
14
|
+
it("is rendered correctly", () => {
|
|
15
|
+
render(<PinInput {...defaultProps} />);
|
|
16
|
+
expect(<PinInput {...defaultProps} />).toMatchSnapshot();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("Input test", () => {
|
|
20
|
+
render(<PinInput {...defaultProps} />);
|
|
21
|
+
|
|
22
|
+
expect(screen.getAllByDisplayValue("1")).toHaveLength(6);
|
|
23
|
+
|
|
24
|
+
expect(screen.getByText("PinTest")).not.toHaveStyle("color:#EA6161");
|
|
25
|
+
expect(screen.getAllByDisplayValue("1")[0]).not.toHaveStyle(
|
|
26
|
+
"border:1px solid #EA6161"
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const inputfocus = screen.getByTestId("pinInput0");
|
|
30
|
+
expect(inputfocus).not.toHaveFocus();
|
|
31
|
+
expect(screen.queryByTestId("pininput-label")).toBeInTheDocument();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test(" Masking test", () => {
|
|
35
|
+
render(<PinInput mask={true} {...defaultProps} />);
|
|
36
|
+
|
|
37
|
+
expect(screen.getAllByDisplayValue("*")).toHaveLength(6);
|
|
38
|
+
expect(screen.queryAllByDisplayValue("1")).not.toHaveLength(6);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test(" AutoFocus test", () => {
|
|
42
|
+
render(<PinInput {...defaultProps} autoFocus={true} />);
|
|
43
|
+
const inputfocus = screen.getByTestId("pinInput0");
|
|
44
|
+
expect(inputfocus).toHaveFocus();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("Invalid Test", () => {
|
|
48
|
+
render(<PinInput {...defaultProps} invalid={true} />);
|
|
49
|
+
|
|
50
|
+
expect(screen.getByText("PinTest")).toHaveStyle("color:#EA6161");
|
|
51
|
+
|
|
52
|
+
const inputsAll = screen.getAllByDisplayValue("1");
|
|
53
|
+
for (let i = 0; i < inputsAll.length; i++) {
|
|
54
|
+
expect(inputsAll[i]).toHaveStyle("border:1px solid #EA6161");
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("disabled test", () => {
|
|
59
|
+
render(<PinInput {...defaultProps} disabled={true} />);
|
|
60
|
+
|
|
61
|
+
const inputsAll = screen.getAllByDisplayValue("1");
|
|
62
|
+
for (let i = 0; i < inputsAll.length; i++) {
|
|
63
|
+
expect(inputsAll[i]).toBeDisabled();
|
|
64
|
+
expect(inputsAll[i]).toHaveStyle("background: transparent");
|
|
65
|
+
expect(inputsAll[i]).toHaveStyle(
|
|
66
|
+
" border:1px solid rgba(192, 192, 238, 0.2)"
|
|
67
|
+
);
|
|
68
|
+
expect(inputsAll[i]).toHaveStyle("cursor:not-allowed");
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
test("No label test", () => {
|
|
72
|
+
render(<PinInput length={6} values={["1", "1", "1", "1", "1", "1"]} />);
|
|
73
|
+
|
|
74
|
+
expect(screen.queryByTestId("pininput-label")).toBeNull();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test("On change test", () => {
|
|
78
|
+
const handleChange = jest.fn();
|
|
79
|
+
render(
|
|
80
|
+
<PinInput {...defaultProps} disabled={true} onChange={handleChange} />
|
|
81
|
+
);
|
|
82
|
+
const inputsAll = screen.getAllByDisplayValue("1");
|
|
83
|
+
for (let i = 0; i < inputsAll.length; i++) {
|
|
84
|
+
fireEvent.change(inputsAll[i], { target: { value: "2" } });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
expect(handleChange).toHaveBeenCalledTimes(6);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import Popper from "../src/components/Popper";
|
|
3
|
+
import { render, fireEvent, cleanup, screen } from "@testing-library/react";
|
|
4
|
+
|
|
5
|
+
afterEach(cleanup);
|
|
6
|
+
|
|
7
|
+
const defaultProps = {
|
|
8
|
+
content: <p>content</p>,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
describe("Popper", () => {
|
|
12
|
+
it("is rendered correctly", () => {
|
|
13
|
+
render(
|
|
14
|
+
<Popper {...defaultProps}>
|
|
15
|
+
<p>Toggle</p>
|
|
16
|
+
</Popper>
|
|
17
|
+
);
|
|
18
|
+
expect(
|
|
19
|
+
<Popper {...defaultProps}>
|
|
20
|
+
<p>Toggle</p>
|
|
21
|
+
</Popper>
|
|
22
|
+
).toMatchSnapshot();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("Click test", () => {
|
|
26
|
+
const handleClick = jest.fn();
|
|
27
|
+
render(
|
|
28
|
+
<Popper {...defaultProps} onClose={handleClick}>
|
|
29
|
+
<p>Toggle</p>
|
|
30
|
+
</Popper>
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const divClick = screen.getByTestId("tooltip-div");
|
|
34
|
+
|
|
35
|
+
//No Click (no content to be shown)
|
|
36
|
+
expect(screen.queryByText("content")).not.toBeInTheDocument();
|
|
37
|
+
|
|
38
|
+
//On Click ( content to be shown)
|
|
39
|
+
fireEvent.click(divClick);
|
|
40
|
+
expect(screen.queryByText("content")).toBeInTheDocument();
|
|
41
|
+
// expect(divClick).toHaveBeenCalledTimes(1);
|
|
42
|
+
|
|
43
|
+
const closeButtonClick = screen.getByTestId("tooltip-close-button");
|
|
44
|
+
|
|
45
|
+
//On Close Button Click (no content to be shown)
|
|
46
|
+
fireEvent.click(closeButtonClick);
|
|
47
|
+
expect(screen.queryByText("content")).not.toBeInTheDocument();
|
|
48
|
+
// expect(closeButtonClick).toHaveBeenCalledTimes(1);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import RewardOMeter from "../src/components/RewardOMeter";
|
|
3
|
+
import { render, fireEvent, screen, getByTestId } from "@testing-library/react";
|
|
4
|
+
import { css } from "@emotion/react";
|
|
5
|
+
|
|
6
|
+
const args = {
|
|
7
|
+
primaryList: {
|
|
8
|
+
data: [
|
|
9
|
+
{ color: "#1ECAA233", percentage: 100 / 6 },
|
|
10
|
+
{ color: "#1ECAA2", percentage: 100 / 6 },
|
|
11
|
+
{ color: "#F9C35C", percentage: 100 / 6 },
|
|
12
|
+
{ color: "#FFB100", percentage: 100 / 6 },
|
|
13
|
+
{ color: "#EA6161", percentage: 100 / 6 },
|
|
14
|
+
{ color: "#AD3030", percentage: 100 / 6 },
|
|
15
|
+
],
|
|
16
|
+
width: 12,
|
|
17
|
+
radius: 85,
|
|
18
|
+
},
|
|
19
|
+
needleProperties: {
|
|
20
|
+
angle: 180 / 3,
|
|
21
|
+
size: 60,
|
|
22
|
+
},
|
|
23
|
+
secondaryList: {
|
|
24
|
+
data: [
|
|
25
|
+
{ color: "#141B3A", percentage: 100 / 6 },
|
|
26
|
+
{ color: "#062646", percentage: 100 / 6 },
|
|
27
|
+
{ color: "#2F2528", percentage: 100 / 6 },
|
|
28
|
+
{ color: "#302100", percentage: 100 / 6 },
|
|
29
|
+
{ color: "#2C122A", percentage: 100 / 6 },
|
|
30
|
+
{ color: "#210915", percentage: 100 / 6 },
|
|
31
|
+
],
|
|
32
|
+
width: 10,
|
|
33
|
+
radius: 74,
|
|
34
|
+
},
|
|
35
|
+
style: css({
|
|
36
|
+
backgroundColor: "#181837",
|
|
37
|
+
}),
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
describe("RewardOMeter", () => {
|
|
41
|
+
it("is rendered correctly", () => {
|
|
42
|
+
render(
|
|
43
|
+
<RewardOMeter {...args} />
|
|
44
|
+
);
|
|
45
|
+
expect(
|
|
46
|
+
<RewardOMeter {...args} />
|
|
47
|
+
).toMatchSnapshot();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test("needle test", () => {
|
|
51
|
+
render(
|
|
52
|
+
<RewardOMeter {...args} />
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
expect(screen.getByTestId("icon")).toBeInTheDocument();
|
|
56
|
+
expect(screen.getByTestId("icon")).toHaveStyle("font-size: 60px;")
|
|
57
|
+
expect(screen.getByTestId("icon")).toHaveStyle("transform: rotate(-30deg);")
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("color rendered properly", () => {
|
|
61
|
+
render(
|
|
62
|
+
<RewardOMeter {...args} />
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
expect(screen.getByRole("img")).toBeInTheDocument();
|
|
66
|
+
|
|
67
|
+
expect(screen.getByTestId("circle-svg0")).toBeInTheDocument();
|
|
68
|
+
expect(screen.getByTestId("circle-svg0")).toHaveAttribute("stroke", "#1ECAA233");
|
|
69
|
+
|
|
70
|
+
expect(screen.getByTestId("circle-svg1")).toBeInTheDocument();
|
|
71
|
+
expect(screen.getByTestId("circle-svg1")).toHaveAttribute("stroke", "#1ECAA2");
|
|
72
|
+
})
|
|
73
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { SearchInput } from "../src/components";
|
|
3
|
+
import { render, fireEvent, screen } from "@testing-library/react";
|
|
4
|
+
import userEvent from "@testing-library/user-event";
|
|
5
|
+
|
|
6
|
+
describe("Search Input test", () => {
|
|
7
|
+
it("is rendered correctly", () => {
|
|
8
|
+
render(
|
|
9
|
+
<SearchInput
|
|
10
|
+
placeholder="Select Coin"
|
|
11
|
+
value=""
|
|
12
|
+
onChange={() => { }}
|
|
13
|
+
/>
|
|
14
|
+
);
|
|
15
|
+
expect(
|
|
16
|
+
<SearchInput
|
|
17
|
+
placeholder="Select Coin"
|
|
18
|
+
value=""
|
|
19
|
+
onChange={() => { }}
|
|
20
|
+
/>
|
|
21
|
+
).toMatchSnapshot();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test("typing input", () => {
|
|
25
|
+
const onChangeHandler = jest.fn();
|
|
26
|
+
render(
|
|
27
|
+
<SearchInput
|
|
28
|
+
placeholder="Select Coin"
|
|
29
|
+
value=""
|
|
30
|
+
onChange={onChangeHandler}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import Select from "../src/components/Select";
|
|
3
|
+
import { render, fireEvent, screen } from "@testing-library/react";
|
|
4
|
+
import { css } from "@emotion/react";
|
|
5
|
+
|
|
6
|
+
const optionsList = [
|
|
7
|
+
{ label: "FIRST", value: "FIRST" },
|
|
8
|
+
{ label: "SECOND", value: "SECOND" },
|
|
9
|
+
{ label: "THIRD", value: "THIRD" },
|
|
10
|
+
{ label: "FOURTH", value: "FOURTH" },
|
|
11
|
+
{ label: "FIFTH", value: "FIFTH" }
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
describe("Select Test", () => {
|
|
15
|
+
it("is rendered correctly", () => {
|
|
16
|
+
render(
|
|
17
|
+
<Select
|
|
18
|
+
placeholder="Select Coin"
|
|
19
|
+
options={[]}
|
|
20
|
+
style={css({})}
|
|
21
|
+
selected=""
|
|
22
|
+
onChange={() => { }}
|
|
23
|
+
/>
|
|
24
|
+
)
|
|
25
|
+
expect(<Select
|
|
26
|
+
placeholder="Select Coin"
|
|
27
|
+
options={[]}
|
|
28
|
+
style={css({})}
|
|
29
|
+
selected=""
|
|
30
|
+
onChange={() => { }}
|
|
31
|
+
/>).toMatchSnapshot();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("dropdown functionality", () => {
|
|
35
|
+
render(
|
|
36
|
+
<Select
|
|
37
|
+
placeholder="Select Coin"
|
|
38
|
+
options={optionsList}
|
|
39
|
+
selected=""
|
|
40
|
+
onChange={() => {}}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
fireEvent.click(screen.getByTestId("button"));
|
|
45
|
+
|
|
46
|
+
expect(screen.getByText("FIRST")).toBeInTheDocument();
|
|
47
|
+
expect(screen.getByText("SECOND")).toBeInTheDocument();
|
|
48
|
+
|
|
49
|
+
fireEvent.click(screen.getByTestId("button"));
|
|
50
|
+
|
|
51
|
+
expect(screen.queryByText("FIRST")).not.toBeInTheDocument();
|
|
52
|
+
expect(screen.queryByText("SECOND")).not.toBeInTheDocument();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("select functionality", () => {
|
|
56
|
+
render(
|
|
57
|
+
<Select
|
|
58
|
+
placeholder="Select Coin"
|
|
59
|
+
options={optionsList}
|
|
60
|
+
style={css({})}
|
|
61
|
+
selected=""
|
|
62
|
+
onChange={() => { }}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
fireEvent.click(screen.getByTestId("button"));
|
|
67
|
+
fireEvent.click(screen.getByText("FIRST"));
|
|
68
|
+
|
|
69
|
+
expect(screen.queryByText("SECOND")).not.toBeInTheDocument();
|
|
70
|
+
expect(screen.queryByText("Select Coin")).not.toBeInTheDocument();
|
|
71
|
+
expect(screen.getByText("FIRST")).toBeInTheDocument();
|
|
72
|
+
|
|
73
|
+
});
|
|
74
|
+
})
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import SidePanel from "../src/components/SidePanel";
|
|
3
|
+
import { render, fireEvent, cleanup, screen } from "@testing-library/react";
|
|
4
|
+
|
|
5
|
+
afterEach(cleanup);
|
|
6
|
+
|
|
7
|
+
const defaultProps = {
|
|
8
|
+
title: "Title",
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
describe("SidePanel", () => {
|
|
12
|
+
it("is rendered correctly", () => {
|
|
13
|
+
render(
|
|
14
|
+
<SidePanel open={true} {...defaultProps}>
|
|
15
|
+
Toggle
|
|
16
|
+
</SidePanel>
|
|
17
|
+
);
|
|
18
|
+
expect(
|
|
19
|
+
<SidePanel open={true} {...defaultProps}>
|
|
20
|
+
Toggle
|
|
21
|
+
</SidePanel>
|
|
22
|
+
).toMatchSnapshot();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("SidePanel Close , with all clicks", () => {
|
|
26
|
+
render(
|
|
27
|
+
<SidePanel open={false} {...defaultProps}>
|
|
28
|
+
<p>Toggle</p>
|
|
29
|
+
</SidePanel>
|
|
30
|
+
);
|
|
31
|
+
expect(screen.queryByTestId("sidepanel-close1")).toBeNull();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("SidePanel Open, back button true", () => {
|
|
35
|
+
const handleCloseClick = jest.fn();
|
|
36
|
+
const handleBackClick = jest.fn();
|
|
37
|
+
render(
|
|
38
|
+
<SidePanel
|
|
39
|
+
open={true}
|
|
40
|
+
{...defaultProps}
|
|
41
|
+
isBack={true}
|
|
42
|
+
onClose={handleCloseClick}
|
|
43
|
+
onBack={handleBackClick}
|
|
44
|
+
>
|
|
45
|
+
<p>Toggle</p>
|
|
46
|
+
</SidePanel>
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const closedivClick1 = screen.getByTestId("sidepanel-close1");
|
|
50
|
+
const closeButtonClick = screen.getByTestId("sidepanel-close2");
|
|
51
|
+
const backClick = screen.getByTestId("sidepanel-back");
|
|
52
|
+
|
|
53
|
+
expect(screen.queryByText("Title")).toBeInTheDocument();
|
|
54
|
+
expect(screen.queryByText("Toggle")).toBeInTheDocument();
|
|
55
|
+
|
|
56
|
+
fireEvent.click(closedivClick1);
|
|
57
|
+
expect(handleCloseClick).toHaveBeenCalledTimes(1);
|
|
58
|
+
|
|
59
|
+
fireEvent.click(closeButtonClick);
|
|
60
|
+
expect(handleCloseClick).toHaveBeenCalledTimes(2);
|
|
61
|
+
|
|
62
|
+
fireEvent.click(backClick);
|
|
63
|
+
expect(handleBackClick).toHaveBeenCalledTimes(1);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test("SidePanel Open, back button false", () => {
|
|
67
|
+
render(
|
|
68
|
+
<SidePanel open={true} {...defaultProps} isBack={false}>
|
|
69
|
+
<p>Toggle</p>
|
|
70
|
+
</SidePanel>
|
|
71
|
+
);
|
|
72
|
+
expect(screen.queryByTestId("sidepanel-back")).toBeNull();
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import Tooltip from "../src/components/Tooltip";
|
|
3
|
+
import { render, fireEvent, cleanup, screen } from "@testing-library/react";
|
|
4
|
+
|
|
5
|
+
afterEach(cleanup);
|
|
6
|
+
|
|
7
|
+
const defaultProps = {
|
|
8
|
+
content: "content",
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
describe("Tooltip", () => {
|
|
12
|
+
//Content shown on hover
|
|
13
|
+
test("hover test", () => {
|
|
14
|
+
render(<Tooltip {...defaultProps} />);
|
|
15
|
+
|
|
16
|
+
const divClick = screen.getByTestId("tooltip");
|
|
17
|
+
//No hover (no content to be shown)
|
|
18
|
+
expect(screen.queryByText("content")).not.toBeInTheDocument();
|
|
19
|
+
fireEvent.mouseOver(divClick);
|
|
20
|
+
|
|
21
|
+
//On hover (content to be shown)
|
|
22
|
+
expect(screen.queryByText("content")).toBeInTheDocument();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("Disabled test", () => {
|
|
26
|
+
render(<Tooltip {...defaultProps} disabled={true} />);
|
|
27
|
+
|
|
28
|
+
const divClick = screen.getByTestId("tooltip");
|
|
29
|
+
//No hover (no content to be shown)
|
|
30
|
+
expect(screen.queryByText("content")).not.toBeInTheDocument();
|
|
31
|
+
fireEvent.mouseOver(divClick);
|
|
32
|
+
|
|
33
|
+
//On hover (no content to be shown)
|
|
34
|
+
expect(screen.queryByText("content")).not.toBeInTheDocument();
|
|
35
|
+
});
|
|
36
|
+
});
|