@bigbinary/neetoui 3.2.66 → 3.2.67
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/formik.js +1 -1
- package/formik.js.LICENSE.txt +0 -15
- package/index.js +1 -1
- package/jest-setup.js +7 -1
- package/layouts.js +1 -1
- package/package.json +2 -2
- package/tests/Accordion.test.js +11 -10
- package/tests/Alert.test.js +126 -0
- package/tests/Button.test.js +6 -5
- package/tests/Collapse.test.js +19 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/neetoui",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.67",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"author": "BigBinary",
|
|
6
6
|
"license": "MIT",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@storybook/react": "^6.4.19",
|
|
53
53
|
"@testing-library/jest-dom": "^5.16.2",
|
|
54
54
|
"@testing-library/react": "^12.1.3",
|
|
55
|
-
"@testing-library/user-event": "^13.
|
|
55
|
+
"@testing-library/user-event": "^13.5.0",
|
|
56
56
|
"autoprefixer": "^9.0.0",
|
|
57
57
|
"babel-eslint": "^10.1.0",
|
|
58
58
|
"babel-jest": "^27.3.1",
|
package/tests/Accordion.test.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Accordion } from "../lib/components";
|
|
3
|
-
import { render,
|
|
3
|
+
import { render, waitForElementToBeRemoved } from "@testing-library/react";
|
|
4
|
+
import userEvent from "@testing-library/user-event";
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
|
|
@@ -29,7 +30,7 @@ describe("Accordion", () => {
|
|
|
29
30
|
<p>Content 1</p>
|
|
30
31
|
</Accordion.Item>
|
|
31
32
|
</Accordion>);
|
|
32
|
-
|
|
33
|
+
userEvent.click(getByText("Item 1"));
|
|
33
34
|
expect(getByText("Content 1")).toBeInTheDocument();
|
|
34
35
|
});
|
|
35
36
|
|
|
@@ -39,12 +40,12 @@ describe("Accordion", () => {
|
|
|
39
40
|
<p>Content 1</p>
|
|
40
41
|
</Accordion.Item>
|
|
41
42
|
</Accordion>);
|
|
42
|
-
|
|
43
|
+
userEvent.click(getByText("Item 1"));
|
|
43
44
|
expect(getByText("Content 1")).toBeInTheDocument();
|
|
44
|
-
|
|
45
|
+
userEvent.keyboard("{space}");
|
|
45
46
|
await waitForElementToBeRemoved(() => queryByText("Content 1"));
|
|
46
47
|
expect(queryByText("Content 1")).not.toBeInTheDocument();
|
|
47
|
-
|
|
48
|
+
userEvent.keyboard("{enter}");
|
|
48
49
|
expect(getByText("Content 1")).toBeInTheDocument();
|
|
49
50
|
});
|
|
50
51
|
|
|
@@ -54,9 +55,9 @@ describe("Accordion", () => {
|
|
|
54
55
|
<p>Content 1</p>
|
|
55
56
|
</Accordion.Item>
|
|
56
57
|
</Accordion>);
|
|
57
|
-
|
|
58
|
+
userEvent.click(getByText("Item 1"));
|
|
58
59
|
expect(getByText("Content 1")).toBeInTheDocument();
|
|
59
|
-
|
|
60
|
+
userEvent.type(getByText("Item 1"), "a");
|
|
60
61
|
expect(getByText("Content 1")).toBeInTheDocument();
|
|
61
62
|
});
|
|
62
63
|
|
|
@@ -67,7 +68,7 @@ describe("Accordion", () => {
|
|
|
67
68
|
<p>Content 1</p>
|
|
68
69
|
</Accordion.Item>
|
|
69
70
|
</Accordion>);
|
|
70
|
-
|
|
71
|
+
userEvent.click(getByText("Item 1"));
|
|
71
72
|
expect(onClick).toHaveBeenCalledTimes(1);
|
|
72
73
|
});
|
|
73
74
|
|
|
@@ -80,9 +81,9 @@ describe("Accordion", () => {
|
|
|
80
81
|
<p>Content 2</p>
|
|
81
82
|
</Accordion.Item>
|
|
82
83
|
</Accordion>);
|
|
83
|
-
|
|
84
|
+
userEvent.click(getByText("Item 1"));
|
|
84
85
|
expect(getByText("Content 1")).toBeInTheDocument();
|
|
85
|
-
|
|
86
|
+
userEvent.click(getByText("Item 2"));
|
|
86
87
|
await waitForElementToBeRemoved(() => queryByText("Content 1"));
|
|
87
88
|
expect(queryByText("Content 1")).not.toBeInTheDocument();
|
|
88
89
|
expect(getByText("Content 2")).toBeInTheDocument();
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Alert } from "../lib/components";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
|
+
import userEvent from "@testing-library/user-event";
|
|
5
|
+
|
|
6
|
+
describe("Alert", () => {
|
|
7
|
+
it("should render without error", () => {
|
|
8
|
+
const { getByText } = render(
|
|
9
|
+
<Alert title="Alert title" message="Alert message" isOpen />
|
|
10
|
+
);
|
|
11
|
+
expect(getByText("Alert title")).toBeInTheDocument();
|
|
12
|
+
expect(getByText("Alert message")).toBeInTheDocument();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("should not display content when isOpen is false", () => {
|
|
16
|
+
const { queryByText } = render(
|
|
17
|
+
<Alert title="Alert title" message="Alert message" isOpen={false} />
|
|
18
|
+
);
|
|
19
|
+
expect(queryByText("Alert title")).not.toBeInTheDocument();
|
|
20
|
+
expect(queryByText("Alert message")).not.toBeInTheDocument();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("should call onClose when close button is clicked", () => {
|
|
24
|
+
const onClose = jest.fn();
|
|
25
|
+
const { getByTestId } = render(
|
|
26
|
+
<Alert
|
|
27
|
+
title="Alert title"
|
|
28
|
+
message="Alert message"
|
|
29
|
+
isOpen
|
|
30
|
+
onClose={onClose}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
userEvent.click(getByTestId("close-button"));
|
|
34
|
+
expect(onClose).toHaveBeenCalledTimes(1);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("should call onSubmit when submit button is clicked", () => {
|
|
38
|
+
const onSubmit = jest.fn();
|
|
39
|
+
const { getByText } = render(
|
|
40
|
+
<Alert
|
|
41
|
+
title="Alert title"
|
|
42
|
+
message="Alert message"
|
|
43
|
+
isOpen
|
|
44
|
+
onSubmit={onSubmit}
|
|
45
|
+
submitButtonLabel="Submit"
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
userEvent.click(getByText("Submit"));
|
|
49
|
+
expect(onSubmit).toHaveBeenCalledTimes(1);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("should call onClose when cancel button is clicked", () => {
|
|
53
|
+
const onClose = jest.fn();
|
|
54
|
+
const { getByText } = render(
|
|
55
|
+
<Alert
|
|
56
|
+
title="Alert title"
|
|
57
|
+
message="Alert message"
|
|
58
|
+
isOpen
|
|
59
|
+
onClose={onClose}
|
|
60
|
+
cancelButtonLabel="Cancel"
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
userEvent.click(getByText("Cancel"));
|
|
64
|
+
expect(onClose).toHaveBeenCalledTimes(1);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("should close the alert when Esc key is pressed", () => {
|
|
68
|
+
const onClose = jest.fn();
|
|
69
|
+
const { container } = render(
|
|
70
|
+
<Alert
|
|
71
|
+
title="Alert title"
|
|
72
|
+
message="Alert message"
|
|
73
|
+
isOpen
|
|
74
|
+
onClose={onClose}
|
|
75
|
+
closeOnEsc
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
userEvent.type(container, "{esc}");
|
|
79
|
+
expect(onClose).toHaveBeenCalledTimes(1);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("should not close the alert when Esc key is pressed when closeOnEsc is false", () => {
|
|
83
|
+
const onClose = jest.fn();
|
|
84
|
+
const { container } = render(
|
|
85
|
+
<Alert
|
|
86
|
+
title="Alert title"
|
|
87
|
+
message="Alert message"
|
|
88
|
+
isOpen
|
|
89
|
+
onClose={onClose}
|
|
90
|
+
closeOnEsc={false}
|
|
91
|
+
/>
|
|
92
|
+
);
|
|
93
|
+
userEvent.type(container, "{esc}");
|
|
94
|
+
expect(onClose).not.toHaveBeenCalled();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("should close alert when clicking outside", () => {
|
|
98
|
+
const onClose = jest.fn();
|
|
99
|
+
const { getByTestId } = render(
|
|
100
|
+
<Alert
|
|
101
|
+
title="Alert title"
|
|
102
|
+
message="Alert message"
|
|
103
|
+
isOpen
|
|
104
|
+
onClose={onClose}
|
|
105
|
+
closeOnOutsideClick
|
|
106
|
+
/>
|
|
107
|
+
);
|
|
108
|
+
userEvent.click(getByTestId("backdrop"));
|
|
109
|
+
expect(onClose).toHaveBeenCalledTimes(1);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("should not close alert when clicking outside when closeOnOutsideClick is false", () => {
|
|
113
|
+
const onClose = jest.fn();
|
|
114
|
+
const { getByTestId } = render(
|
|
115
|
+
<Alert
|
|
116
|
+
title="Alert title"
|
|
117
|
+
message="Alert message"
|
|
118
|
+
isOpen
|
|
119
|
+
onClose={onClose}
|
|
120
|
+
closeOnOutsideClick={false}
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
123
|
+
userEvent.click(getByTestId("backdrop"));
|
|
124
|
+
expect(onClose).not.toHaveBeenCalled();
|
|
125
|
+
});
|
|
126
|
+
});
|
package/tests/Button.test.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Button } from "../lib/components";
|
|
3
|
-
import { render
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
4
|
import { BrowserRouter } from "react-router-dom";
|
|
5
|
+
import userEvent from "@testing-library/user-event";
|
|
5
6
|
|
|
6
7
|
describe("Button", () => {
|
|
7
8
|
it("should render without error", () => {
|
|
@@ -12,7 +13,7 @@ describe("Button", () => {
|
|
|
12
13
|
it("should call onClick on button click", () => {
|
|
13
14
|
const onClick = jest.fn();
|
|
14
15
|
const { getByText } = render(<Button label="Button" onClick={onClick} />);
|
|
15
|
-
|
|
16
|
+
userEvent.click(getByText("Button"));
|
|
16
17
|
expect(onClick).toHaveBeenCalledTimes(1);
|
|
17
18
|
});
|
|
18
19
|
|
|
@@ -21,7 +22,7 @@ describe("Button", () => {
|
|
|
21
22
|
const { getByText } = render(
|
|
22
23
|
<Button label="Button" onClick={onClick} disabled />
|
|
23
24
|
);
|
|
24
|
-
|
|
25
|
+
userEvent.click(getByText("Button"));
|
|
25
26
|
expect(onClick).toHaveBeenCalledTimes(0);
|
|
26
27
|
});
|
|
27
28
|
|
|
@@ -30,7 +31,7 @@ describe("Button", () => {
|
|
|
30
31
|
const { getByText } = render(
|
|
31
32
|
<Button label="Button" onClick={onClick} loading />
|
|
32
33
|
);
|
|
33
|
-
|
|
34
|
+
userEvent.click(getByText("Button"));
|
|
34
35
|
expect(onClick).toHaveBeenCalledTimes(0);
|
|
35
36
|
});
|
|
36
37
|
|
|
@@ -38,7 +39,7 @@ describe("Button", () => {
|
|
|
38
39
|
const { getByText } = render(
|
|
39
40
|
<Button label="Button" tooltipProps={{ content: "Tooltip" }} />
|
|
40
41
|
);
|
|
41
|
-
|
|
42
|
+
userEvent.hover(getByText("Button"));
|
|
42
43
|
expect(getByText("Tooltip")).toBeInTheDocument();
|
|
43
44
|
});
|
|
44
45
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@testing-library/react";
|
|
3
|
+
import Collapse from "../lib/components/Accordion/Collapse";
|
|
4
|
+
|
|
5
|
+
describe("Collapse", () => {
|
|
6
|
+
it("should render without error", () => {
|
|
7
|
+
const { getByText } = render(<Collapse open>
|
|
8
|
+
<p>Content</p>
|
|
9
|
+
</Collapse>);
|
|
10
|
+
expect(getByText("Content")).toBeInTheDocument();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("should not display content when collapsed", () => {
|
|
14
|
+
const { queryByText } = render(<Collapse>
|
|
15
|
+
<p>Content</p>
|
|
16
|
+
</Collapse>);
|
|
17
|
+
expect(queryByText("Content")).not.toBeInTheDocument();
|
|
18
|
+
});
|
|
19
|
+
});
|