@bigbinary/neetoui 3.2.69 → 3.2.72

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.69",
3
+ "version": "3.2.72",
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,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,116 @@
1
+ import React from "react";
2
+ import { Modal, Typography, Button } from "../lib/components";
3
+ import { render } from "@testing-library/react";
4
+ import userEvent from "@testing-library/user-event";
5
+
6
+ describe("Modal", () => {
7
+ it("should render without error", () => {
8
+ const { getByText } = render(
9
+ <Modal isOpen>
10
+ <Modal.Header>
11
+ <Typography style="h2">Modal Header</Typography>
12
+ </Modal.Header>
13
+ </Modal>
14
+ );
15
+ expect(getByText("Modal Header")).toBeInTheDocument();
16
+ });
17
+
18
+ it("should not display content when isOpen is false", () => {
19
+ const { queryByText } = render(
20
+ <Modal>
21
+ <Modal.Header>
22
+ <Typography style="h2">Modal Header</Typography>
23
+ </Modal.Header>
24
+ </Modal>
25
+ );
26
+ expect(queryByText("Modal Header")).not.toBeInTheDocument();
27
+ });
28
+
29
+ it("should render body", () => {
30
+ const { getByText } = render(
31
+ <Modal isOpen>
32
+ <Modal.Body>
33
+ <Typography style="body2" lineHeight="normal">
34
+ Sample body text
35
+ </Typography>
36
+ </Modal.Body>
37
+ </Modal>
38
+ );
39
+ expect(getByText("Sample body text")).toBeInTheDocument();
40
+ });
41
+
42
+ it("should render footer ", () => {
43
+ const { getByText } = render(
44
+ <Modal isOpen>
45
+ <Modal.Footer>
46
+ <Button label="Submit" size="large" />
47
+ </Modal.Footer>
48
+ </Modal>
49
+ );
50
+ expect(getByText("Submit")).toBeInTheDocument();
51
+ });
52
+
53
+ it("should not show close button when closeButton is false", () => {
54
+ const { queryByTestId } = render(
55
+ <Modal isOpen closeButton={false}>
56
+ <Modal.Body>Sample text</Modal.Body>
57
+ </Modal>
58
+ );
59
+ expect(queryByTestId("close-button")).not.toBeInTheDocument();
60
+ });
61
+
62
+ it("should trigger onClose on close button is clicked", () => {
63
+ const onClose = jest.fn();
64
+ const { getByTestId } = render(
65
+ <Modal isOpen onClose={onClose}>
66
+ <Modal.Body>Sample text</Modal.Body>
67
+ </Modal>
68
+ );
69
+ userEvent.click(getByTestId("close-button"));
70
+ expect(onClose).toHaveBeenCalledTimes(1);
71
+ });
72
+
73
+ it("should close the modal when Esc key is pressed", () => {
74
+ const onClose = jest.fn();
75
+ const { container } = render(
76
+ <Modal isOpen onClose={onClose}>
77
+ <Modal.Body>Sample text</Modal.Body>
78
+ </Modal>
79
+ );
80
+ userEvent.type(container, "{esc}");
81
+ expect(onClose).toHaveBeenCalledTimes(1);
82
+ });
83
+
84
+ it("should not close the modal when Esc key is pressed when closeOnEsc is false", () => {
85
+ const onClose = jest.fn();
86
+ const { container } = render(
87
+ <Modal isOpen onClose={onClose} closeOnEsc={false}>
88
+ <Modal.Body>Sample text</Modal.Body>
89
+ </Modal>
90
+ );
91
+ userEvent.type(container, "{esc}");
92
+ expect(onClose).not.toHaveBeenCalled();
93
+ });
94
+
95
+ it("should close modal when clicking outside", () => {
96
+ const onClose = jest.fn();
97
+ const { getByTestId } = render(
98
+ <Modal isOpen onClose={onClose} closeOnOutsideClick>
99
+ <Modal.Body>Sample text</Modal.Body>
100
+ </Modal>
101
+ );
102
+ userEvent.click(getByTestId("backdrop"));
103
+ expect(onClose).toHaveBeenCalledTimes(1);
104
+ });
105
+
106
+ it("should not close modal when clicking outside when closeOnOutsideClick is false", () => {
107
+ const onClose = jest.fn();
108
+ const { getByTestId } = render(
109
+ <Modal isOpen onClose={onClose} closeOnOutsideClick={false}>
110
+ <Modal.Body>Sample text</Modal.Body>
111
+ </Modal>
112
+ );
113
+ userEvent.click(getByTestId("backdrop"));
114
+ expect(onClose).not.toHaveBeenCalled();
115
+ });
116
+ });
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ import { PageLoader } from "../lib/components";
3
+ import { render } from "@testing-library/react";
4
+
5
+ describe("PageLoader", () => {
6
+ it("should render without error", () => {
7
+ const { getByTestId } = render(<PageLoader data-testid="pageloader"/>);
8
+ expect(getByTestId("pageloader")).toBeInTheDocument();
9
+ });
10
+
11
+ it("should render text without error", () => {
12
+ const { getByText } = render(<PageLoader text="Loading"/>);
13
+ expect(getByText("Loading")).toBeInTheDocument();
14
+ });
15
+ });
@@ -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
+ });