zebpay-ui 0.0.43 → 0.0.44
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 +1 -1
- package/tests/Accordion.test.tsx +0 -40
- package/tests/Avatar.test.tsx +0 -76
- package/tests/Button.test.tsx +0 -35
- package/tests/Input.test.tsx +0 -39
- package/tests/PinInput.test.tsx +0 -89
- package/tests/Popper.test.tsx +0 -50
- package/tests/RewardOMeter.test.tsx +0 -73
- package/tests/SearchInput.test.tsx +0 -34
- package/tests/Select.test.tsx +0 -74
- package/tests/SidePanel.test.tsx +0 -74
- package/tests/Tooltip.test.tsx +0 -36
- package/tests/__snapshots__/Accordion.test.tsx.snap +0 -11
- package/tests/__snapshots__/Button.test.tsx.snap +0 -10
- package/tests/__snapshots__/PinInput.test.tsx.snap +0 -18
- package/tests/__snapshots__/Popper.test.tsx.snap +0 -15
- package/tests/__snapshots__/SidePanel.test.tsx.snap +0 -10
package/package.json
CHANGED
package/tests/Accordion.test.tsx
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import Accordion from "../src/components/Accordion";
|
|
3
|
-
import { render, fireEvent, cleanup, screen } from "@testing-library/react";
|
|
4
|
-
|
|
5
|
-
afterEach(cleanup);
|
|
6
|
-
|
|
7
|
-
const defaultProps = {
|
|
8
|
-
title: "Testing",
|
|
9
|
-
isOpen: true,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
describe("Accordion Test", () => {
|
|
13
|
-
it("is rendered correctly", () => {
|
|
14
|
-
render(
|
|
15
|
-
<Accordion onToggle={() => {}} {...defaultProps}>
|
|
16
|
-
Accordion content
|
|
17
|
-
</Accordion>
|
|
18
|
-
);
|
|
19
|
-
expect(
|
|
20
|
-
<Accordion onToggle={() => {}} {...defaultProps}>
|
|
21
|
-
Accordion content
|
|
22
|
-
</Accordion>
|
|
23
|
-
).toMatchSnapshot();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test("is clicked", () => {
|
|
27
|
-
const handleClick = jest.fn();
|
|
28
|
-
render(
|
|
29
|
-
<Accordion isOpen={true} onToggle={handleClick} title={"Testing"}>
|
|
30
|
-
<p>AB</p>
|
|
31
|
-
</Accordion>
|
|
32
|
-
);
|
|
33
|
-
const divClick = screen.getByTestId("accordion");
|
|
34
|
-
fireEvent.click(divClick);
|
|
35
|
-
|
|
36
|
-
expect(screen.queryByText("AB")).toBeInTheDocument();
|
|
37
|
-
|
|
38
|
-
expect(handleClick).toHaveBeenCalledTimes(1);
|
|
39
|
-
});
|
|
40
|
-
});
|
package/tests/Avatar.test.tsx
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import Avatar from "../src/components/Avatar";
|
|
3
|
-
import { render, fireEvent, cleanup, screen } from "@testing-library/react";
|
|
4
|
-
|
|
5
|
-
afterEach(cleanup);
|
|
6
|
-
|
|
7
|
-
const defaultProps = {
|
|
8
|
-
src: "abc",
|
|
9
|
-
alt: "abc",
|
|
10
|
-
id: 1,
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
describe("Avatar Test", () => {
|
|
14
|
-
it("is rendered correctly", () => {
|
|
15
|
-
render(<Avatar {...defaultProps} spacing="medium" />);
|
|
16
|
-
expect(<Avatar {...defaultProps} spacing="medium" />).toMatchSnapshot();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
test("is clicked", () => {
|
|
20
|
-
const handleClick = jest.fn();
|
|
21
|
-
render(<Avatar {...defaultProps} spacing="medium" onClick={handleClick} />);
|
|
22
|
-
const divClick = screen.getByTestId("avatar");
|
|
23
|
-
|
|
24
|
-
fireEvent.click(divClick);
|
|
25
|
-
expect(handleClick).toHaveBeenCalledTimes(1);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test("custom Child", () => {
|
|
29
|
-
render(
|
|
30
|
-
<Avatar {...defaultProps} spacing="medium">
|
|
31
|
-
W
|
|
32
|
-
</Avatar>
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
expect(screen.queryByText("W")).toBeInTheDocument();
|
|
36
|
-
});
|
|
37
|
-
test("loading state", () => {
|
|
38
|
-
render(
|
|
39
|
-
<Avatar {...defaultProps} spacing="medium" loading={true}>
|
|
40
|
-
W
|
|
41
|
-
</Avatar>
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
expect(screen.queryByText("W")).not.toBeInTheDocument();
|
|
45
|
-
expect(screen.queryByTestId("avatar")).not.toBeInTheDocument();
|
|
46
|
-
expect(screen.queryByTestId("shimmer")).toBeInTheDocument();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test("size small change", () => {
|
|
50
|
-
render(
|
|
51
|
-
<Avatar {...defaultProps} spacing="medium" size="small" loading={true}>
|
|
52
|
-
W
|
|
53
|
-
</Avatar>
|
|
54
|
-
);
|
|
55
|
-
expect(screen.getByTestId("shimmer")).toHaveStyle("width:24px");
|
|
56
|
-
expect(screen.getByTestId("shimmer")).toHaveStyle("height:24px");
|
|
57
|
-
});
|
|
58
|
-
test("size medium change", () => {
|
|
59
|
-
render(
|
|
60
|
-
<Avatar {...defaultProps} spacing="medium" size="medium" loading={true}>
|
|
61
|
-
W
|
|
62
|
-
</Avatar>
|
|
63
|
-
);
|
|
64
|
-
expect(screen.getByTestId("shimmer")).toHaveStyle("width:28px");
|
|
65
|
-
expect(screen.getByTestId("shimmer")).toHaveStyle("height:28px");
|
|
66
|
-
});
|
|
67
|
-
test("size large change", () => {
|
|
68
|
-
render(
|
|
69
|
-
<Avatar {...defaultProps} spacing="medium" size="large" loading={true}>
|
|
70
|
-
W
|
|
71
|
-
</Avatar>
|
|
72
|
-
);
|
|
73
|
-
expect(screen.getByTestId("shimmer")).toHaveStyle("width:32px");
|
|
74
|
-
expect(screen.getByTestId("shimmer")).toHaveStyle("height:32px");
|
|
75
|
-
});
|
|
76
|
-
});
|
package/tests/Button.test.tsx
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
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
|
-
});
|
package/tests/Input.test.tsx
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
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
|
-
});
|
package/tests/PinInput.test.tsx
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
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
|
-
});
|
package/tests/Popper.test.tsx
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,73 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
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
|
-
});
|
package/tests/Select.test.tsx
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
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
|
-
})
|
package/tests/SidePanel.test.tsx
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
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
|
-
});
|
package/tests/Tooltip.test.tsx
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
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
|
-
});
|