@popsure/dirty-swan 0.27.30 → 0.27.31
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/dist/App.d.ts +0 -1
- package/dist/index.js +71 -74
- package/dist/index.js.map +1 -1
- package/dist/lib/components/autocompleteAddress/demo.d.ts +0 -1
- package/dist/lib/components/autocompleteAddress/index.d.ts +0 -1
- package/dist/lib/components/button/index.d.ts +1 -1
- package/dist/lib/components/chip/index.d.ts +0 -1
- package/dist/lib/components/comparisonTable/components/AccordionItem/AccordionItem.d.ts +0 -1
- package/dist/lib/components/comparisonTable/components/Chevron.d.ts +0 -1
- package/dist/lib/components/comparisonTable/components/Row/index.d.ts +0 -1
- package/dist/lib/components/comparisonTable/components/TableArrows/Arrow.d.ts +0 -1
- package/dist/lib/components/comparisonTable/components/TableArrows/index.d.ts +0 -1
- package/dist/lib/components/comparisonTable/components/TableInfoButton/index.d.ts +0 -1
- package/dist/lib/components/comparisonTable/components/TableRating/StarIcon.d.ts +0 -1
- package/dist/lib/components/comparisonTable/components/TableRating/ZapIcon.d.ts +0 -1
- package/dist/lib/components/comparisonTable/components/TableRating/index.d.ts +0 -1
- package/dist/lib/components/comparisonTable/components/TableRowHeader/index.d.ts +0 -1
- package/dist/lib/components/comparisonTable/components/TableTrueFalse.d.ts +0 -1
- package/dist/lib/components/dateSelector/index.d.ts +0 -1
- package/dist/lib/components/input/autoSuggestInput/index.d.ts +0 -1
- package/dist/lib/components/input/autoSuggestMultiSelect/index.d.ts +0 -1
- package/dist/lib/components/input/currency/index.d.ts +0 -1
- package/dist/lib/components/input/iban/index.d.ts +0 -1
- package/dist/lib/components/input/index.d.ts +1 -1
- package/dist/lib/components/modal/bottomModal/index.d.ts +0 -1
- package/dist/lib/components/modal/bottomOrRegularModal/index.d.ts +0 -1
- package/dist/lib/components/modal/regularModal/index.d.ts +0 -1
- package/dist/lib/components/multiDropzone/index.d.ts +0 -1
- package/dist/lib/components/segmentedControl/index.d.ts +0 -1
- package/dist/lib/scss/private/base/demo.d.ts +0 -1
- package/dist/lib/scss/public/demo.d.ts +0 -1
- package/dist/lib/util/testUtils/customRender.d.ts +7 -0
- package/dist/lib/util/testUtils/index.d.ts +2 -0
- package/package.json +5 -3
- package/src/lib/components/autocompleteAddress/index.test.tsx +22 -21
- package/src/lib/components/input/currency/index.test.tsx +22 -22
- package/src/lib/components/input/index.tsx +3 -6
- package/src/lib/components/modal/regularModal/index.tsx +14 -12
- package/src/lib/components/modal/regularModal/style.module.scss +16 -15
- package/src/lib/components/multiDropzone/index.test.tsx +21 -26
- package/src/lib/components/segmentedControl/index.test.tsx +15 -21
- package/src/lib/util/testUtils/customRender.tsx +15 -0
- package/src/lib/util/testUtils/index.ts +5 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { fireEvent, render } from '
|
|
2
|
-
import { act } from 'react-dom/test-utils';
|
|
1
|
+
import { act, fireEvent, render } from '../../util/testUtils';
|
|
3
2
|
import '@testing-library/jest-dom';
|
|
4
3
|
|
|
5
4
|
import MultiDropzone, { MultiDropzoneProps } from '.';
|
|
@@ -36,13 +35,10 @@ const setup = ({
|
|
|
36
35
|
|
|
37
36
|
describe('MultiDropzone component', () => {
|
|
38
37
|
it("should call onFileSelect on files change", async () => {
|
|
39
|
-
const
|
|
40
|
-
const input = screen.getByTestId(inputTestId);
|
|
38
|
+
const { getByTestId, user } = setup({});
|
|
41
39
|
const files = [file, file];
|
|
42
40
|
|
|
43
|
-
await
|
|
44
|
-
fireEvent.change(input, { target: { files } });
|
|
45
|
-
});
|
|
41
|
+
await user.upload(getByTestId(inputTestId), files);
|
|
46
42
|
|
|
47
43
|
expect(mockOnFileSelect).toHaveBeenCalledWith(files);
|
|
48
44
|
});
|
|
@@ -61,46 +57,45 @@ describe('MultiDropzone component', () => {
|
|
|
61
57
|
});
|
|
62
58
|
|
|
63
59
|
it("should show max file size error message", async () => {
|
|
64
|
-
const
|
|
65
|
-
const input = screen.getByTestId(inputTestId);
|
|
60
|
+
const { getByTestId, getByText, user } = setup({ maxSize: 10 });
|
|
66
61
|
const bigFile = file;
|
|
67
62
|
Object.defineProperty(bigFile, 'size', { value: 1024 });
|
|
68
63
|
|
|
69
|
-
await
|
|
70
|
-
fireEvent.change(input, { target: { files: [bigFile] } });
|
|
71
|
-
});
|
|
64
|
+
await user.upload(getByTestId(inputTestId), [bigFile]);
|
|
72
65
|
|
|
73
66
|
expect(
|
|
74
|
-
|
|
67
|
+
getByText("File is too large. It must be less than 10 Bytes.")
|
|
75
68
|
).toBeInTheDocument();
|
|
76
69
|
});
|
|
77
70
|
|
|
78
71
|
it("should show wrong filetype error message", async () => {
|
|
79
|
-
const
|
|
80
|
-
const input =
|
|
81
|
-
|
|
72
|
+
const { getByTestId, getByText } = setup({ accept: "document" });
|
|
73
|
+
const input = getByTestId(inputTestId);
|
|
74
|
+
|
|
82
75
|
await act(async () => {
|
|
76
|
+
// Keeping fireevent to emulate file change like drop
|
|
77
|
+
// Using userevent.upload doesn't work since input has an accept/html validation
|
|
83
78
|
fireEvent.change(input, { target: { files: [file] } });
|
|
84
79
|
});
|
|
85
|
-
|
|
80
|
+
|
|
86
81
|
expect(
|
|
87
|
-
|
|
82
|
+
getByText("File type must be one of DOC, DOCX, PDF")
|
|
88
83
|
).toBeInTheDocument();
|
|
89
84
|
});
|
|
90
85
|
|
|
91
86
|
it("should remove wrong filetype error message", async () => {
|
|
92
|
-
const
|
|
93
|
-
const input =
|
|
94
|
-
|
|
87
|
+
const { getByAltText, getByTestId, queryByText, user } = setup({ accept: "document" });
|
|
88
|
+
const input = getByTestId(inputTestId);
|
|
89
|
+
|
|
95
90
|
await act(async () => {
|
|
91
|
+
// Keeping fireevent to emulate file change like drop
|
|
92
|
+
// Using userevent.upload doesn't work since input has an accept/html validation
|
|
96
93
|
fireEvent.change(input, { target: { files: [file] } });
|
|
97
94
|
});
|
|
98
|
-
|
|
99
|
-
screen.getByAltText("remove").click();
|
|
100
95
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
).not.toBeInTheDocument();
|
|
96
|
+
await user.click(getByAltText("remove"));
|
|
97
|
+
|
|
98
|
+
expect(queryByText("File type must be one of DOC, DOCX, PDF")).not.toBeInTheDocument();
|
|
104
99
|
});
|
|
105
100
|
});
|
|
106
101
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { render } from '../../util/testUtils';
|
|
2
2
|
|
|
3
3
|
import SegmentedControl from '.';
|
|
4
4
|
|
|
@@ -15,36 +15,30 @@ const setup = (onChange: (selectedIndex: number) => void = () => {}) => {
|
|
|
15
15
|
describe('SegmentedControl component', () => {
|
|
16
16
|
it('Should provide the index of the clicked button', async () => {
|
|
17
17
|
const callback = jest.fn();
|
|
18
|
-
const
|
|
19
|
-
const buttons =
|
|
18
|
+
const { getAllByRole, user } = setup(callback);
|
|
19
|
+
const buttons = getAllByRole('button');
|
|
20
20
|
|
|
21
21
|
// click first button
|
|
22
|
-
|
|
22
|
+
await user.click(buttons[0]);
|
|
23
23
|
|
|
24
24
|
// click second button
|
|
25
|
-
|
|
25
|
+
await user.click(buttons[1]);
|
|
26
26
|
|
|
27
27
|
expect(callback.mock.calls).toEqual([[0], [1]]);
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
it('Should provide the index of the selected button on key down', async () => {
|
|
31
31
|
const callback = jest.fn();
|
|
32
|
-
const
|
|
33
|
-
const buttons =
|
|
34
|
-
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// select second button on key down
|
|
43
|
-
fireEvent.keyDown(buttons[1], {
|
|
44
|
-
key: 'Enter',
|
|
45
|
-
code: 'Enter',
|
|
46
|
-
charCode: 13,
|
|
47
|
-
});
|
|
32
|
+
const { getAllByRole, user } = setup(callback);
|
|
33
|
+
const buttons = getAllByRole('button');
|
|
34
|
+
|
|
35
|
+
// focus first button and select with keyboard
|
|
36
|
+
buttons[0].focus();
|
|
37
|
+
await user.keyboard('{enter}');
|
|
38
|
+
|
|
39
|
+
// focus second button and select with keyboard
|
|
40
|
+
buttons[1].focus();
|
|
41
|
+
await user.keyboard('{enter}');
|
|
48
42
|
|
|
49
43
|
expect(callback.mock.calls).toEqual([[0], [1]]);
|
|
50
44
|
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { render, RenderOptions, RenderResult } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { UserEvent } from '@testing-library/user-event/dist/types/setup/setup';
|
|
4
|
+
|
|
5
|
+
interface CustomRenderResult extends RenderResult {
|
|
6
|
+
user: UserEvent;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const customRender = (
|
|
10
|
+
ui: JSX.Element,
|
|
11
|
+
options: RenderOptions = {}
|
|
12
|
+
): CustomRenderResult => ({
|
|
13
|
+
user: userEvent.setup(),
|
|
14
|
+
...render(ui, options),
|
|
15
|
+
});
|