@bigbinary/neetoui 3.2.70 → 3.2.71
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/index.js +1 -1
- package/package.json +1 -1
- package/tests/Checkbox.test.js +43 -0
- package/tests/Spinner.test.js +10 -0
package/package.json
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Checkbox } from "../lib/components";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
|
+
import userEvent from "@testing-library/user-event";
|
|
5
|
+
|
|
6
|
+
describe("Checkbox", () => {
|
|
7
|
+
it("should render without error", () => {
|
|
8
|
+
const { getByRole } = render(<Checkbox label="Checkbox" />);
|
|
9
|
+
expect(getByRole("checkbox")).toBeInTheDocument();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("should call onChange when checkbox value is changed", () => {
|
|
13
|
+
const onChange = jest.fn();
|
|
14
|
+
const { getByRole } = render(
|
|
15
|
+
<Checkbox label="Checkbox" onChange={onChange} />
|
|
16
|
+
);
|
|
17
|
+
userEvent.click(getByRole("checkbox"));
|
|
18
|
+
expect(onChange).toHaveBeenCalledTimes(1);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("should display error message", () => {
|
|
22
|
+
const { getByText } = render(
|
|
23
|
+
<Checkbox label="Checkbox" error="Error message" />
|
|
24
|
+
);
|
|
25
|
+
expect(getByText("Error message")).toBeInTheDocument();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("should be unchecked by default", () => {
|
|
29
|
+
const { getByRole } = render(
|
|
30
|
+
<Checkbox label="Checkbox"/>
|
|
31
|
+
);
|
|
32
|
+
expect(getByRole("checkbox")).not.toBeChecked();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("should be checked on clicking the checkbox", () => {
|
|
36
|
+
const { getByRole } = render(
|
|
37
|
+
<Checkbox label="Checkbox"/>
|
|
38
|
+
);
|
|
39
|
+
const checkbox = getByRole("checkbox");
|
|
40
|
+
userEvent.click(checkbox);
|
|
41
|
+
expect(checkbox).toBeChecked();
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Spinner } from "../lib/components";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
|
+
|
|
5
|
+
describe("Spinner", () => {
|
|
6
|
+
it("should render without error", () => {
|
|
7
|
+
const { getByTestId } = render(<Spinner/>);
|
|
8
|
+
expect(getByTestId("spinner")).toBeInTheDocument();
|
|
9
|
+
});
|
|
10
|
+
});
|