@bigbinary/neetoui 3.2.68 → 3.2.69
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/Tag.test.js +40 -0
package/package.json
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Tag } from "../lib/components";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
|
+
import userEvent from "@testing-library/user-event";
|
|
5
|
+
|
|
6
|
+
describe("Tag", () => {
|
|
7
|
+
it("should render without error", () => {
|
|
8
|
+
const { getByText } = render(<Tag label="Tag" />);
|
|
9
|
+
expect(getByText("Tag")).toBeInTheDocument();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("should show icon when icon string is provided", () => {
|
|
13
|
+
const { getByTestId } = render(<Tag icon="check" />);
|
|
14
|
+
expect(getByTestId("class-icon")).toBeInTheDocument();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("should show indicator when indicatorColor is provided", () => {
|
|
18
|
+
const { getByTestId } = render(<Tag indicatorColor="green" />);
|
|
19
|
+
expect(getByTestId("tag-indicator")).toBeInTheDocument();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("should show close button if onClose function is provided", () => {
|
|
23
|
+
const { getByTestId } = render(<Tag onClose={() => {}} />);
|
|
24
|
+
expect(getByTestId("tag-close-button")).toBeInTheDocument();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("should call onClose on button click", () => {
|
|
28
|
+
const onClose = jest.fn();
|
|
29
|
+
const { getByTestId } = render(<Tag onClose={onClose} />);
|
|
30
|
+
userEvent.click(getByTestId("tag-close-button"));
|
|
31
|
+
expect(onClose).toHaveBeenCalledTimes(1);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("should not call onClose function if tag is disabled", () => {
|
|
35
|
+
const onClose = jest.fn();
|
|
36
|
+
const { getByTestId } = render(<Tag onClose={onClose} disabled />);
|
|
37
|
+
userEvent.click(getByTestId("tag-close-button"));
|
|
38
|
+
expect(onClose).toHaveBeenCalledTimes(0);
|
|
39
|
+
});
|
|
40
|
+
});
|