@bigbinary/neetoui 3.2.75 → 3.2.76
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/.circleci/config.yml +8 -2
- package/formik.js +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/tests/EmailInput.test.js +1 -1
- package/tests/Switch.test.js +61 -0
- package/tests/Tab.test.js +60 -0
package/package.json
CHANGED
package/tests/EmailInput.test.js
CHANGED
|
@@ -157,7 +157,7 @@ describe("EmailInput", () => {
|
|
|
157
157
|
{ label: "test@example.com", value: "test@example.com", valid: true },
|
|
158
158
|
{ label: "invalidEmail", value: "invalidEmail" },
|
|
159
159
|
]}
|
|
160
|
-
filterInvalidEmails
|
|
160
|
+
filterInvalidEmails={{}}
|
|
161
161
|
error="Invalid email"
|
|
162
162
|
/>
|
|
163
163
|
);
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Switch } from "../lib/components";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
|
+
import userEvent from "@testing-library/user-event";
|
|
5
|
+
|
|
6
|
+
describe("Switch", () => {
|
|
7
|
+
it("should render without error", () => {
|
|
8
|
+
const { getByRole } = render(<Switch />);
|
|
9
|
+
const switchButton = getByRole("checkbox");
|
|
10
|
+
expect(switchButton).toBeInTheDocument();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("should be unchecked by default", () => {
|
|
14
|
+
const { getByRole } = render(<Switch />);
|
|
15
|
+
const switchButton = getByRole("checkbox");
|
|
16
|
+
expect(switchButton).not.toBeChecked();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("should be checked on clicking the checkbox", () => {
|
|
20
|
+
const { getByRole } = render(<Switch />);
|
|
21
|
+
const switchButton = getByRole("checkbox");
|
|
22
|
+
userEvent.click(switchButton);
|
|
23
|
+
expect(switchButton).toBeChecked();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("should render label", () => {
|
|
27
|
+
const { getByText } = render(<Switch label="Switch" />);
|
|
28
|
+
const label = getByText("Switch");
|
|
29
|
+
expect(label).toBeInTheDocument();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("should render asterisk when required is set to true", () => {
|
|
33
|
+
const { getByText } = render(<Switch required label="Switch" />);
|
|
34
|
+
const asterisk = getByText("*");
|
|
35
|
+
expect(asterisk).toBeInTheDocument();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("should display error message", () => {
|
|
39
|
+
const { getByText } = render(<Switch error="Error message" />);
|
|
40
|
+
const errorMessage = getByText("Error message");
|
|
41
|
+
expect(errorMessage).toBeInTheDocument();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("should be disabled if disabled is true", () => {
|
|
45
|
+
const { getByRole } = render(<Switch disabled />);
|
|
46
|
+
const switchButton = getByRole("checkbox");
|
|
47
|
+
expect(switchButton).toBeDisabled();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("should render check icon icon when checked is true", () => {
|
|
51
|
+
const { getByTestId } = render(<Switch checked />);
|
|
52
|
+
const checkIcon = getByTestId("check-icon");
|
|
53
|
+
expect(checkIcon).toBeInTheDocument();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("should render close icon icon when checked is false", () => {
|
|
57
|
+
const { getByTestId } = render(<Switch checked={false} />);
|
|
58
|
+
const closeIcon = getByTestId("close-icon");
|
|
59
|
+
expect(closeIcon).toBeInTheDocument();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import { Tab } from "../lib/components";
|
|
5
|
+
import { BrowserRouter } from "react-router-dom";
|
|
6
|
+
|
|
7
|
+
describe("Tab", () => {
|
|
8
|
+
it("should render without error", () => {
|
|
9
|
+
render(
|
|
10
|
+
<Tab>
|
|
11
|
+
<Tab.Item>Tab 1</Tab.Item>
|
|
12
|
+
<Tab.Item>Tab 2</Tab.Item>
|
|
13
|
+
</Tab>
|
|
14
|
+
);
|
|
15
|
+
expect(screen.getByText("Tab 1")).toBeInTheDocument();
|
|
16
|
+
expect(screen.getByText("Tab 2")).toBeInTheDocument();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("should render a link when activeClassName is provided", () => {
|
|
20
|
+
render(<BrowserRouter>
|
|
21
|
+
<Tab>
|
|
22
|
+
<Tab.Item activeClassName="active" to="/route">Tab 1</Tab.Item>
|
|
23
|
+
<Tab.Item>Tab 2</Tab.Item>
|
|
24
|
+
</Tab>
|
|
25
|
+
</BrowserRouter>);
|
|
26
|
+
expect(screen.getByRole("link")).toBeInTheDocument();
|
|
27
|
+
expect(screen.getByRole("link")).toHaveAttribute("href", "/route");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("should render icon when provided", () => {
|
|
31
|
+
render(<Tab>
|
|
32
|
+
<Tab.Item icon={() => <svg data-testid="svg-icon" />}>Tab 1</Tab.Item>
|
|
33
|
+
</Tab>);
|
|
34
|
+
expect(screen.getByTestId("svg-icon")).toBeInTheDocument();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("should render icon when icon className is provided", () => {
|
|
38
|
+
render(<Tab>
|
|
39
|
+
<Tab.Item icon="icon">Tab 1</Tab.Item>
|
|
40
|
+
</Tab>);
|
|
41
|
+
expect(screen.getByTestId("tab-icon")).toBeInTheDocument();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("should call onClick when clicked on Tab", () => {
|
|
45
|
+
const onClick = jest.fn();
|
|
46
|
+
render(<Tab>
|
|
47
|
+
<Tab.Item icon="icon" onClick={onClick}>Tab 1</Tab.Item>
|
|
48
|
+
</Tab>);
|
|
49
|
+
userEvent.click(screen.getByText("Tab 1"));
|
|
50
|
+
expect(onClick).toHaveBeenCalled();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("should make the tab active when active prop is true", () => {
|
|
54
|
+
render(<Tab>
|
|
55
|
+
<Tab.Item active>Tab 1</Tab.Item>
|
|
56
|
+
<Tab.Item>Tab 2</Tab.Item>
|
|
57
|
+
</Tab>);
|
|
58
|
+
expect(screen.getByText("Tab 1")).toHaveClass("active");
|
|
59
|
+
});
|
|
60
|
+
});
|