@bigbinary/neetoui 3.2.79 → 3.2.82
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.css +1 -1
- package/index.js +1 -1
- package/layouts.js +1 -1
- package/package.json +1 -1
- package/.circleci/config.yml +0 -37
- package/.eslint-rules/imports/enforced.js +0 -20
- package/.eslint-rules/imports/order.js +0 -15
- package/.eslint-rules/overrides.js +0 -12
- package/.eslint-rules/react.js +0 -34
- package/jest-setup.js +0 -22
- package/tests/Accordion.test.js +0 -103
- package/tests/ActionDropdown.test.js +0 -61
- package/tests/Alert.test.js +0 -126
- package/tests/Button.test.js +0 -73
- package/tests/Callout.test.js +0 -20
- package/tests/Checkbox.test.js +0 -43
- package/tests/Collapse.test.js +0 -19
- package/tests/ColorPicker.test.js +0 -117
- package/tests/DatePicker.test.js +0 -111
- package/tests/Dropdown.test.js +0 -185
- package/tests/EmailInput.test.js +0 -166
- package/tests/Input.test.js +0 -75
- package/tests/Label.test.js +0 -61
- package/tests/Modal.test.js +0 -116
- package/tests/PageLoader.test.js +0 -15
- package/tests/Pagination.test.js +0 -125
- package/tests/Pane.test.js +0 -116
- package/tests/Radio.test.js +0 -83
- package/tests/Select.test.js +0 -85
- package/tests/Spinner.test.js +0 -10
- package/tests/Switch.test.js +0 -61
- package/tests/Tab.test.js +0 -60
- package/tests/Table.test.js +0 -204
- package/tests/Tag.test.js +0 -40
- package/tests/Textarea.test.js +0 -51
- package/tests/TimePicker.test.js +0 -92
- package/tests/Toastr.test.js +0 -217
- package/tests/Tooltip.test.js +0 -44
- package/tests/Typography.test.js +0 -20
package/package.json
CHANGED
package/.circleci/config.yml
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
version: 2.1
|
|
2
|
-
aliases:
|
|
3
|
-
- &test_environment
|
|
4
|
-
docker:
|
|
5
|
-
# replace with your preferred image
|
|
6
|
-
- image: cimg/node:16.13.2
|
|
7
|
-
jobs:
|
|
8
|
-
"Snapshot Test":
|
|
9
|
-
<<: *test_environment
|
|
10
|
-
steps:
|
|
11
|
-
- checkout
|
|
12
|
-
- run: yarn install
|
|
13
|
-
- run:
|
|
14
|
-
name: Run Snapshot Tests
|
|
15
|
-
command: yarn chromatic test --exit-zero-on-changes --project-token $CHROMATIC_PROJECT_TOKEN
|
|
16
|
-
"Unit Test":
|
|
17
|
-
<<: *test_environment
|
|
18
|
-
steps:
|
|
19
|
-
- checkout
|
|
20
|
-
- restore_cache:
|
|
21
|
-
key: dependency-cache-{{ checksum "yarn.lock" }}
|
|
22
|
-
- run: yarn install
|
|
23
|
-
- save_cache:
|
|
24
|
-
key: dependency-cache-{{ checksum "yarn.lock" }}
|
|
25
|
-
paths:
|
|
26
|
-
- ./node_modules
|
|
27
|
-
- run:
|
|
28
|
-
name: Run Unit Tests
|
|
29
|
-
command: yarn test --runInBand
|
|
30
|
-
|
|
31
|
-
workflows:
|
|
32
|
-
neetoui-tests:
|
|
33
|
-
jobs:
|
|
34
|
-
- "Snapshot Test"
|
|
35
|
-
- "Unit Test"
|
|
36
|
-
|
|
37
|
-
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
rules: {
|
|
3
|
-
// not-auto-fixable: Prefer a default export if module exports a single name.
|
|
4
|
-
"import/prefer-default-export": "off",
|
|
5
|
-
// not-auto-fixable: Forbid a module from importing a module with a dependency path back to itself.
|
|
6
|
-
"import/no-cycle": ["error", { maxDepth: 1, ignoreExternal: true }],
|
|
7
|
-
// not-auto-fixable: Prevent unnecessary path segments in import and require statements.
|
|
8
|
-
"import/no-useless-path-segments": ["error", { noUselessIndex: true }],
|
|
9
|
-
// not-auto-fixable: Report any invalid exports, i.e. re-export of the same name.
|
|
10
|
-
"import/export": "error",
|
|
11
|
-
// not-auto-fixable: Forbid the use of mutable exports with var or let.
|
|
12
|
-
"import/no-mutable-exports": "error",
|
|
13
|
-
// not-auto-fixable: Ensure all imports appear before other statements.
|
|
14
|
-
"import/first": "error",
|
|
15
|
-
// not-auto-fixable: Ensure all exports appear after other statements.
|
|
16
|
-
"import/exports-last": "error",
|
|
17
|
-
// auto-fixable: Enforce a newline after import statements.
|
|
18
|
-
"import/newline-after-import": ["error", { count: 1 }]
|
|
19
|
-
}
|
|
20
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
rules: {
|
|
3
|
-
// auto-fixable: Enforce a convention in module import order - we enforce https://www.bigbinary.com/react-best-practices/sort-import-statements
|
|
4
|
-
"import/order": [
|
|
5
|
-
"error",
|
|
6
|
-
{
|
|
7
|
-
"newlines-between": "always",
|
|
8
|
-
alphabetize: { order: "asc", caseInsensitive: true },
|
|
9
|
-
warnOnUnassignedImports: true,
|
|
10
|
-
// Ignore react imports so that they're always ordered to the top of the file.
|
|
11
|
-
pathGroupsExcludedImportTypes: ["react", "react-native"],
|
|
12
|
-
},
|
|
13
|
-
],
|
|
14
|
-
},
|
|
15
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
// Currently we are using this section for excluding certain files from certain rules.
|
|
3
|
-
overrides: [
|
|
4
|
-
{
|
|
5
|
-
files: [".eslintrc.js", "*.json"],
|
|
6
|
-
rules: {
|
|
7
|
-
"import/order": "off",
|
|
8
|
-
"react-hooks/rules-of-hooks": "off",
|
|
9
|
-
},
|
|
10
|
-
},
|
|
11
|
-
],
|
|
12
|
-
};
|
package/.eslint-rules/react.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
rules: {
|
|
3
|
-
// not-auto-fixable: Prevent missing props validation in a React component definition.
|
|
4
|
-
"react/prop-types": "off",
|
|
5
|
-
// not-auto-fixable: Detect unescaped HTML entities, which might represent malformed tags.
|
|
6
|
-
"react/no-unescaped-entities": "off",
|
|
7
|
-
// not-auto-fixable: Prevent missing displayName in a React component definition. Useful when using React extensions in browser and checking for component name.
|
|
8
|
-
"react/display-name": "error",
|
|
9
|
-
// not-auto-fixable: Reports when this.state is accessed within setState.
|
|
10
|
-
"react/no-access-state-in-setstate": "error",
|
|
11
|
-
// not-auto-fixable: Prevent usage of dangerous JSX props. Currently jam3 plugin will take care of handling this.
|
|
12
|
-
"react/no-danger": "off",
|
|
13
|
-
// not-auto-fixable: Report when a DOM element is using both children and dangerouslySetInnerHTML.
|
|
14
|
-
"react/no-danger-with-children": "warn",
|
|
15
|
-
// not-auto-fixable: Prevent definitions of unused prop types.
|
|
16
|
-
"react/no-unused-prop-types": "error",
|
|
17
|
-
// not-auto-fixable: Report missing key props in iterators/collection literals. Important rule!
|
|
18
|
-
"react/jsx-key": "error",
|
|
19
|
-
// not-auto-fixable: Enforce no duplicate props.
|
|
20
|
-
"react/jsx-no-duplicate-props": "error",
|
|
21
|
-
// not-auto-fixable: Disallow undeclared variables in JSX.
|
|
22
|
-
"react/jsx-no-undef": "error",
|
|
23
|
-
// not-auto-fixable: Enforce PascalCase for user-defined JSX components.
|
|
24
|
-
"react/jsx-pascal-case": ["error", { allowNamespace: true }],
|
|
25
|
-
// not-auto-fixable: Prevent React to be incorrectly marked as unused.
|
|
26
|
-
"react/jsx-uses-react": "error",
|
|
27
|
-
// not-auto-fixable: Prevent variables used in JSX to be marked as unused.
|
|
28
|
-
"react/jsx-uses-vars": "error",
|
|
29
|
-
// not-auto-fixable: Ensures https://reactjs.org/docs/hooks-rules.html.
|
|
30
|
-
"react-hooks/rules-of-hooks": "error",
|
|
31
|
-
// not-auto-fixable: Ensures https://reactjs.org/docs/hooks-rules.html - Checks effect dependencies.
|
|
32
|
-
"react-hooks/exhaustive-deps": "warn",
|
|
33
|
-
},
|
|
34
|
-
};
|
package/jest-setup.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import "@testing-library/jest-dom";
|
|
2
|
-
|
|
3
|
-
// Fixes element.getTotalLength is not a function. Refer: https://github.com/framer/motion/issues/204
|
|
4
|
-
if (!SVGElement.prototype.getTotalLength) {
|
|
5
|
-
SVGElement.prototype.getTotalLength = () => 1;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
//Fixes ReferenceError: ResizeObserver is not defined
|
|
9
|
-
global.ResizeObserver = require('resize-observer-polyfill')
|
|
10
|
-
|
|
11
|
-
//Fixes TypeError: window.matchMedia is not a function
|
|
12
|
-
Object.defineProperty(window, 'matchMedia', {
|
|
13
|
-
writable: true,
|
|
14
|
-
value: jest.fn().mockImplementation((query) => ({
|
|
15
|
-
matches: false,
|
|
16
|
-
media: query,
|
|
17
|
-
onchange: null,
|
|
18
|
-
addListener: jest.fn(), // Deprecated
|
|
19
|
-
removeListener: jest.fn(), // Deprecated
|
|
20
|
-
}
|
|
21
|
-
)),
|
|
22
|
-
});
|
package/tests/Accordion.test.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Accordion } from "../lib/components";
|
|
3
|
-
import { render, waitForElementToBeRemoved } from "@testing-library/react";
|
|
4
|
-
import userEvent from "@testing-library/user-event";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
describe("Accordion", () => {
|
|
9
|
-
it("should render without error", () => {
|
|
10
|
-
const { getByText } = render(<Accordion>
|
|
11
|
-
<Accordion.Item title="Item 1">
|
|
12
|
-
<p>Content 1</p>
|
|
13
|
-
</Accordion.Item>
|
|
14
|
-
</Accordion>);
|
|
15
|
-
expect(getByText("Item 1")).toBeInTheDocument();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("should not render content when accordion is closed", () => {
|
|
19
|
-
const { queryByText } = render(<Accordion>
|
|
20
|
-
<Accordion.Item title="Item 1">
|
|
21
|
-
<p>Content 1</p>
|
|
22
|
-
</Accordion.Item>
|
|
23
|
-
</Accordion>);
|
|
24
|
-
expect(queryByText("Content 1")).not.toBeInTheDocument();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("should open accordion and render content when accordion title is clicked", () => {
|
|
28
|
-
const { getByText } = render(<Accordion>
|
|
29
|
-
<Accordion.Item title="Item 1">
|
|
30
|
-
<p>Content 1</p>
|
|
31
|
-
</Accordion.Item>
|
|
32
|
-
</Accordion>);
|
|
33
|
-
userEvent.click(getByText("Item 1"));
|
|
34
|
-
expect(getByText("Content 1")).toBeInTheDocument();
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("should toggle accordion when Enter or Space key is pressed", async () => {
|
|
38
|
-
const { getByText, queryByText } = render(<Accordion>
|
|
39
|
-
<Accordion.Item title="Item 1">
|
|
40
|
-
<p>Content 1</p>
|
|
41
|
-
</Accordion.Item>
|
|
42
|
-
</Accordion>);
|
|
43
|
-
userEvent.click(getByText("Item 1"));
|
|
44
|
-
expect(getByText("Content 1")).toBeInTheDocument();
|
|
45
|
-
userEvent.keyboard("{space}");
|
|
46
|
-
await waitForElementToBeRemoved(() => queryByText("Content 1"));
|
|
47
|
-
expect(queryByText("Content 1")).not.toBeInTheDocument();
|
|
48
|
-
userEvent.keyboard("{enter}");
|
|
49
|
-
expect(getByText("Content 1")).toBeInTheDocument();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("should not toggle accordion when any other keys are pressed", () => {
|
|
53
|
-
const { getByText } = render(<Accordion>
|
|
54
|
-
<Accordion.Item title="Item 1">
|
|
55
|
-
<p>Content 1</p>
|
|
56
|
-
</Accordion.Item>
|
|
57
|
-
</Accordion>);
|
|
58
|
-
userEvent.click(getByText("Item 1"));
|
|
59
|
-
expect(getByText("Content 1")).toBeInTheDocument();
|
|
60
|
-
userEvent.type(getByText("Item 1"), "a");
|
|
61
|
-
expect(getByText("Content 1")).toBeInTheDocument();
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("should trigger onClick when title is clicked", () => {
|
|
65
|
-
const onClick = jest.fn();
|
|
66
|
-
const { getByText } = render(<Accordion>
|
|
67
|
-
<Accordion.Item title="Item 1" onClick={onClick}>
|
|
68
|
-
<p>Content 1</p>
|
|
69
|
-
</Accordion.Item>
|
|
70
|
-
</Accordion>);
|
|
71
|
-
userEvent.click(getByText("Item 1"));
|
|
72
|
-
expect(onClick).toHaveBeenCalledTimes(1);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("should only open one accordion at a time", async () => {
|
|
76
|
-
const { getByText, queryByText } = render(<Accordion>
|
|
77
|
-
<Accordion.Item title="Item 1">
|
|
78
|
-
<p>Content 1</p>
|
|
79
|
-
</Accordion.Item>
|
|
80
|
-
<Accordion.Item title="Item 2">
|
|
81
|
-
<p>Content 2</p>
|
|
82
|
-
</Accordion.Item>
|
|
83
|
-
</Accordion>);
|
|
84
|
-
userEvent.click(getByText("Item 1"));
|
|
85
|
-
expect(getByText("Content 1")).toBeInTheDocument();
|
|
86
|
-
userEvent.click(getByText("Item 2"));
|
|
87
|
-
await waitForElementToBeRemoved(() => queryByText("Content 1"));
|
|
88
|
-
expect(queryByText("Content 1")).not.toBeInTheDocument();
|
|
89
|
-
expect(getByText("Content 2")).toBeInTheDocument();
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it("should open the the accordion when defaultActiveKey is provided", () => {
|
|
93
|
-
const { getByText } = render(<Accordion defaultActiveKey={1}>
|
|
94
|
-
<Accordion.Item title="Item 1">
|
|
95
|
-
<p>Content 1</p>
|
|
96
|
-
</Accordion.Item>
|
|
97
|
-
<Accordion.Item title="Item 2">
|
|
98
|
-
<p>Content 2</p>
|
|
99
|
-
</Accordion.Item>
|
|
100
|
-
</Accordion>);
|
|
101
|
-
expect(getByText("Content 2")).toBeInTheDocument();
|
|
102
|
-
});
|
|
103
|
-
});
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ActionDropdown } from "../lib/components";
|
|
3
|
-
import { render, screen } from "@testing-library/react";
|
|
4
|
-
import userEvent from "@testing-library/user-event";
|
|
5
|
-
|
|
6
|
-
describe("ActionDropdown", () => {
|
|
7
|
-
it("should render without error", () => {
|
|
8
|
-
render(
|
|
9
|
-
<ActionDropdown label="ActionDropdown">
|
|
10
|
-
<li>Option 1</li>
|
|
11
|
-
<li>Option 2</li>
|
|
12
|
-
</ActionDropdown>
|
|
13
|
-
);
|
|
14
|
-
expect(screen.getByText("ActionDropdown")).toBeInTheDocument();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("should call onClick on button click", () => {
|
|
18
|
-
const onClick = jest.fn();
|
|
19
|
-
render(
|
|
20
|
-
<ActionDropdown label="ActionDropdown" onClick={onClick}>
|
|
21
|
-
<li>Option 1</li>
|
|
22
|
-
<li>Option 2</li>
|
|
23
|
-
</ActionDropdown>
|
|
24
|
-
);
|
|
25
|
-
const button = screen.getByTestId("action-dropdown-btn");
|
|
26
|
-
userEvent.click(button);
|
|
27
|
-
expect(onClick).toHaveBeenCalledTimes(1);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("should not call onClick on button click when disabled", () => {
|
|
31
|
-
const onClick = jest.fn();
|
|
32
|
-
render(
|
|
33
|
-
<ActionDropdown label="ActionDropdown" disabled>
|
|
34
|
-
<li>Option 1</li>
|
|
35
|
-
<li>Option 2</li>
|
|
36
|
-
</ActionDropdown>
|
|
37
|
-
);
|
|
38
|
-
userEvent.click(screen.getByText("ActionDropdown"));
|
|
39
|
-
expect(onClick).toHaveBeenCalledTimes(0);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("should show options on clicking dropdown", async () => {
|
|
43
|
-
render(
|
|
44
|
-
<ActionDropdown
|
|
45
|
-
dropdownProps={{
|
|
46
|
-
buttonProps: {
|
|
47
|
-
"data-testid": "action-dropdown-dropdown",
|
|
48
|
-
},
|
|
49
|
-
}}
|
|
50
|
-
label="ActionDropdown"
|
|
51
|
-
>
|
|
52
|
-
<li>Option 1</li>
|
|
53
|
-
<li>Option 2</li>
|
|
54
|
-
</ActionDropdown>
|
|
55
|
-
);
|
|
56
|
-
const dropdown = screen.getByTestId("action-dropdown-dropdown");
|
|
57
|
-
userEvent.click(dropdown);
|
|
58
|
-
expect(await screen.findByText("Option 1")).toBeInTheDocument();
|
|
59
|
-
expect(await screen.findByText("Option 2")).toBeInTheDocument();
|
|
60
|
-
});
|
|
61
|
-
});
|
package/tests/Alert.test.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Alert } from "../lib/components";
|
|
3
|
-
import { render } from "@testing-library/react";
|
|
4
|
-
import userEvent from "@testing-library/user-event";
|
|
5
|
-
|
|
6
|
-
describe("Alert", () => {
|
|
7
|
-
it("should render without error", () => {
|
|
8
|
-
const { getByText } = render(
|
|
9
|
-
<Alert title="Alert title" message="Alert message" isOpen />
|
|
10
|
-
);
|
|
11
|
-
expect(getByText("Alert title")).toBeInTheDocument();
|
|
12
|
-
expect(getByText("Alert message")).toBeInTheDocument();
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it("should not display content when isOpen is false", () => {
|
|
16
|
-
const { queryByText } = render(
|
|
17
|
-
<Alert title="Alert title" message="Alert message" isOpen={false} />
|
|
18
|
-
);
|
|
19
|
-
expect(queryByText("Alert title")).not.toBeInTheDocument();
|
|
20
|
-
expect(queryByText("Alert message")).not.toBeInTheDocument();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("should call onClose when close button is clicked", () => {
|
|
24
|
-
const onClose = jest.fn();
|
|
25
|
-
const { getByTestId } = render(
|
|
26
|
-
<Alert
|
|
27
|
-
title="Alert title"
|
|
28
|
-
message="Alert message"
|
|
29
|
-
isOpen
|
|
30
|
-
onClose={onClose}
|
|
31
|
-
/>
|
|
32
|
-
);
|
|
33
|
-
userEvent.click(getByTestId("close-button"));
|
|
34
|
-
expect(onClose).toHaveBeenCalledTimes(1);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("should call onSubmit when submit button is clicked", () => {
|
|
38
|
-
const onSubmit = jest.fn();
|
|
39
|
-
const { getByText } = render(
|
|
40
|
-
<Alert
|
|
41
|
-
title="Alert title"
|
|
42
|
-
message="Alert message"
|
|
43
|
-
isOpen
|
|
44
|
-
onSubmit={onSubmit}
|
|
45
|
-
submitButtonLabel="Submit"
|
|
46
|
-
/>
|
|
47
|
-
);
|
|
48
|
-
userEvent.click(getByText("Submit"));
|
|
49
|
-
expect(onSubmit).toHaveBeenCalledTimes(1);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("should call onClose when cancel button is clicked", () => {
|
|
53
|
-
const onClose = jest.fn();
|
|
54
|
-
const { getByText } = render(
|
|
55
|
-
<Alert
|
|
56
|
-
title="Alert title"
|
|
57
|
-
message="Alert message"
|
|
58
|
-
isOpen
|
|
59
|
-
onClose={onClose}
|
|
60
|
-
cancelButtonLabel="Cancel"
|
|
61
|
-
/>
|
|
62
|
-
);
|
|
63
|
-
userEvent.click(getByText("Cancel"));
|
|
64
|
-
expect(onClose).toHaveBeenCalledTimes(1);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("should close the alert when Esc key is pressed", () => {
|
|
68
|
-
const onClose = jest.fn();
|
|
69
|
-
const { container } = render(
|
|
70
|
-
<Alert
|
|
71
|
-
title="Alert title"
|
|
72
|
-
message="Alert message"
|
|
73
|
-
isOpen
|
|
74
|
-
onClose={onClose}
|
|
75
|
-
closeOnEsc
|
|
76
|
-
/>
|
|
77
|
-
);
|
|
78
|
-
userEvent.type(container, "{esc}");
|
|
79
|
-
expect(onClose).toHaveBeenCalledTimes(1);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it("should not close the alert when Esc key is pressed when closeOnEsc is false", () => {
|
|
83
|
-
const onClose = jest.fn();
|
|
84
|
-
const { container } = render(
|
|
85
|
-
<Alert
|
|
86
|
-
title="Alert title"
|
|
87
|
-
message="Alert message"
|
|
88
|
-
isOpen
|
|
89
|
-
onClose={onClose}
|
|
90
|
-
closeOnEsc={false}
|
|
91
|
-
/>
|
|
92
|
-
);
|
|
93
|
-
userEvent.type(container, "{esc}");
|
|
94
|
-
expect(onClose).not.toHaveBeenCalled();
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it("should close alert when clicking outside", () => {
|
|
98
|
-
const onClose = jest.fn();
|
|
99
|
-
const { getByTestId } = render(
|
|
100
|
-
<Alert
|
|
101
|
-
title="Alert title"
|
|
102
|
-
message="Alert message"
|
|
103
|
-
isOpen
|
|
104
|
-
onClose={onClose}
|
|
105
|
-
closeOnOutsideClick
|
|
106
|
-
/>
|
|
107
|
-
);
|
|
108
|
-
userEvent.click(getByTestId("backdrop"));
|
|
109
|
-
expect(onClose).toHaveBeenCalledTimes(1);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it("should not close alert when clicking outside when closeOnOutsideClick is false", () => {
|
|
113
|
-
const onClose = jest.fn();
|
|
114
|
-
const { getByTestId } = render(
|
|
115
|
-
<Alert
|
|
116
|
-
title="Alert title"
|
|
117
|
-
message="Alert message"
|
|
118
|
-
isOpen
|
|
119
|
-
onClose={onClose}
|
|
120
|
-
closeOnOutsideClick={false}
|
|
121
|
-
/>
|
|
122
|
-
);
|
|
123
|
-
userEvent.click(getByTestId("backdrop"));
|
|
124
|
-
expect(onClose).not.toHaveBeenCalled();
|
|
125
|
-
});
|
|
126
|
-
});
|
package/tests/Button.test.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Button } from "../lib/components";
|
|
3
|
-
import { render } from "@testing-library/react";
|
|
4
|
-
import { BrowserRouter } from "react-router-dom";
|
|
5
|
-
import userEvent from "@testing-library/user-event";
|
|
6
|
-
|
|
7
|
-
describe("Button", () => {
|
|
8
|
-
it("should render without error", () => {
|
|
9
|
-
const { getByText } = render(<Button label="Button" />);
|
|
10
|
-
expect(getByText("Button")).toBeInTheDocument();
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("should call onClick on button click", () => {
|
|
14
|
-
const onClick = jest.fn();
|
|
15
|
-
const { getByText } = render(<Button label="Button" onClick={onClick} />);
|
|
16
|
-
userEvent.click(getByText("Button"));
|
|
17
|
-
expect(onClick).toHaveBeenCalledTimes(1);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("should not call onClick on button click when disabled", () => {
|
|
21
|
-
const onClick = jest.fn();
|
|
22
|
-
const { getByText } = render(
|
|
23
|
-
<Button label="Button" onClick={onClick} disabled />
|
|
24
|
-
);
|
|
25
|
-
userEvent.click(getByText("Button"));
|
|
26
|
-
expect(onClick).toHaveBeenCalledTimes(0);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("should not call onClick on button click when loading", () => {
|
|
30
|
-
const onClick = jest.fn();
|
|
31
|
-
const { getByText } = render(
|
|
32
|
-
<Button label="Button" onClick={onClick} loading />
|
|
33
|
-
);
|
|
34
|
-
userEvent.click(getByText("Button"));
|
|
35
|
-
expect(onClick).toHaveBeenCalledTimes(0);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it("should show tooltip when button is hovered", () => {
|
|
39
|
-
const { getByText } = render(
|
|
40
|
-
<Button label="Button" tooltipProps={{ content: "Tooltip" }} />
|
|
41
|
-
);
|
|
42
|
-
userEvent.hover(getByText("Button"));
|
|
43
|
-
expect(getByText("Tooltip")).toBeInTheDocument();
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("should show icon when icon string is provided", () => {
|
|
47
|
-
const { getByTestId } = render(<Button icon="check" />);
|
|
48
|
-
expect(getByTestId("class-icon")).toBeInTheDocument();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("should show icon when icon component is provided", () => {
|
|
52
|
-
const { getByTestId } = render(
|
|
53
|
-
<Button icon={() => <svg data-testid="svg-icon" />} />
|
|
54
|
-
);
|
|
55
|
-
expect(getByTestId("svg-icon")).toBeInTheDocument();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("should render a link when `href` prop is given", () => {
|
|
59
|
-
const { getByRole } = render(
|
|
60
|
-
<Button label="Link" href="https://example.com" />
|
|
61
|
-
);
|
|
62
|
-
expect(getByRole("link")).toHaveAttribute("href", "https://example.com");
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("should render a router link when `to` prop is given", () => {
|
|
66
|
-
const { getByRole } = render(
|
|
67
|
-
<BrowserRouter>
|
|
68
|
-
<Button label="Router Link" to="/some-path" />
|
|
69
|
-
</BrowserRouter>
|
|
70
|
-
);
|
|
71
|
-
expect(getByRole("link")).toHaveAttribute("href", "/some-path");
|
|
72
|
-
});
|
|
73
|
-
});
|
package/tests/Callout.test.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
});
|
package/tests/Checkbox.test.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
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
|
-
});
|
package/tests/Collapse.test.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render } from "@testing-library/react";
|
|
3
|
-
import Collapse from "../lib/components/Accordion/Collapse";
|
|
4
|
-
|
|
5
|
-
describe("Collapse", () => {
|
|
6
|
-
it("should render without error", () => {
|
|
7
|
-
const { getByText } = render(<Collapse open>
|
|
8
|
-
<p>Content</p>
|
|
9
|
-
</Collapse>);
|
|
10
|
-
expect(getByText("Content")).toBeInTheDocument();
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("should not display content when collapsed", () => {
|
|
14
|
-
const { queryByText } = render(<Collapse>
|
|
15
|
-
<p>Content</p>
|
|
16
|
-
</Collapse>);
|
|
17
|
-
expect(queryByText("Content")).not.toBeInTheDocument();
|
|
18
|
-
});
|
|
19
|
-
});
|