@bigbinary/neetoui 3.2.67 → 3.2.70

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/neetoui",
3
- "version": "3.2.67",
3
+ "version": "3.2.70",
4
4
  "main": "./index.js",
5
5
  "author": "BigBinary",
6
6
  "license": "MIT",
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import { Callout } from "../lib/components";
3
+ import { Check } from "@bigbinary/neeto-icons";
4
+ import { render } from "@testing-library/react";
5
+
6
+ describe("Callout", () => {
7
+ it("should render without error", () => {
8
+ const { getByText } = render(
9
+ <Callout>
10
+ <p>Tesing Callout</p>
11
+ </Callout>
12
+ );
13
+ expect(getByText("Tesing Callout")).toBeInTheDocument();
14
+ });
15
+
16
+ it("should show icon when icon component is provided", () => {
17
+ const { getByTestId } = render(<Callout icon={Check} />);
18
+ expect(getByTestId("callout-icon")).toBeInTheDocument();
19
+ });
20
+ });
@@ -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
+ });
@@ -0,0 +1,51 @@
1
+ import React from "react";
2
+ import { render } from "@testing-library/react";
3
+ import { Textarea } from "../lib/components";
4
+ import userEvent from "@testing-library/user-event";
5
+
6
+ describe("Textarea", () => {
7
+ it("should render without error", () => {
8
+ const { getByLabelText } = render(<Textarea id="text" label="Textarea" />);
9
+ expect(getByLabelText("Textarea")).toBeInTheDocument();
10
+ });
11
+
12
+ it("should update value on input when uncontrolled", () => {
13
+ const { getByLabelText } = render(<Textarea id="text" label="Textarea" />);
14
+ const textarea = getByLabelText("Textarea");
15
+ userEvent.type(textarea, "Test");
16
+ expect(textarea).toHaveValue("Test");
17
+ });
18
+
19
+ it("should call onChange when textarea value changes", () => {
20
+ const onChange = jest.fn();
21
+ const { getByLabelText } = render(
22
+ <Textarea id="text" label="Textarea" onChange={onChange} />
23
+ );
24
+ userEvent.type(getByLabelText("Textarea"), "Test");
25
+ expect(onChange).toHaveBeenCalledTimes(4);
26
+ });
27
+
28
+ it("should display helpText", () => {
29
+ const { getByText } = render(<Textarea id="text" label="Textarea" helpText="Help text" />);
30
+ expect(getByText("Help text")).toBeInTheDocument();
31
+ });
32
+
33
+ it("should display error message", () => {
34
+ const { getByText } = render(
35
+ <Textarea id="text" label="Textarea" error="Error message" />
36
+ );
37
+ expect(getByText("Error message")).toBeInTheDocument();
38
+ });
39
+
40
+ it("should properly handle maxLength", () => {
41
+ const { getByLabelText, getByText } = render(
42
+ <Textarea id="text" label="Textarea" maxLength={5} />
43
+ );
44
+ expect(getByText("0 / 5")).toBeInTheDocument();
45
+ expect(getByLabelText("Textarea")).toHaveAttribute("maxLength", "5");
46
+
47
+ userEvent.type(getByLabelText("Textarea"), "Testing maxLength");
48
+ expect(getByText("5 / 5")).toBeInTheDocument();
49
+ expect(getByLabelText("Textarea")).toHaveValue("Testi");
50
+ });
51
+ });
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import { Typography } from "../lib/components";
3
+ import { render } from "@testing-library/react";
4
+
5
+ describe("Typography", () => {
6
+ it("should render without error", () => {
7
+ const { getByText } = render(<Typography style="body1">Typography</Typography>);
8
+ expect(getByText("Typography")).toBeInTheDocument();
9
+ });
10
+
11
+ it("should render a heading when style is of heading type", () => {
12
+ const { getByRole } = render(<Typography style="h1">Typography</Typography>);
13
+ expect(getByRole("heading", { level: 1 })).toBeInTheDocument();
14
+ });
15
+
16
+ it("should override default tag when component prop is given", () => {
17
+ const { getByRole } = render(<Typography style="h1" component="h2">Typography</Typography>);
18
+ expect(getByRole("heading", { level: 2 })).toBeInTheDocument();
19
+ });
20
+ });