@woosmap/ui 3.192.0 → 4.0.0
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/.eslintrc +2 -0
- package/.storybook/main.js +16 -13
- package/package.json +39 -37
- package/src/components/CopyClipboardButton/CopyToClipboard.test.js +4 -5
- package/src/components/Demo/GeolocationDemo.js +1 -0
- package/src/components/Demo/LocalitiesAllDemo.js +1 -0
- package/src/components/Demo/LocalitiesDemo.js +1 -0
- package/src/components/Demo/LocalitiesFRAddressDemo.js +1 -1
- package/src/components/Demo/LocalitiesUKAddressDemo.js +1 -1
- package/src/components/Demo/MapDemo.js +1 -1
- package/src/components/Demo/MerchantDemo.js +1 -0
- package/src/components/Dropdown/Dropdown.test.js +1 -2
- package/src/components/DynamicTag/DynamicTag.stories.js +4 -0
- package/src/components/DynamicTag/DynamicTag.test.js +8 -8
- package/src/components/InfoMessage/InfoMessage.stories.js +1 -0
- package/src/components/InfoMessage/InfoMessage.test.js +2 -3
- package/src/components/Modal/Modal.test.js +2 -3
- package/src/components/Panel/Panel.js +1 -0
- package/src/components/PasswordStrengthBar/PasswordStrengthBar.js +21 -19
- package/src/components/PasswordStrengthBar/PasswordStrengthBar.stories.js +4 -0
- package/src/components/PasswordStrengthBar/PasswordStrengthBar.test.js +0 -7
- package/src/components/Select/Select.js +1 -0
- package/src/components/SnackBar/SnackBar.test.js +6 -6
- package/src/components/Switch/Switch.test.js +1 -2
- package/src/components/Tab/Tab.stories.js +1 -0
- package/src/components/Tab/Tab.test.js +3 -4
- package/src/components/withClickOutside/withClickOutside.test.js +3 -4
- package/src/components/withFormValidation/withFormValidation.test.js +4 -5
package/.eslintrc
CHANGED
package/.storybook/main.js
CHANGED
|
@@ -30,19 +30,19 @@ const getStylusLoader = (cssOptions) => {
|
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
loader: require.resolve('postcss-loader'),
|
|
33
|
-
options: {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
sourceMap: shouldUseSourceMap,
|
|
45
|
-
},
|
|
33
|
+
// options: {
|
|
34
|
+
// ident: 'postcss',
|
|
35
|
+
// plugins: () => [
|
|
36
|
+
// require('postcss-flexbugs-fixes'),
|
|
37
|
+
// require('postcss-preset-env')({
|
|
38
|
+
// autoprefixer: {
|
|
39
|
+
// flexbox: 'no-2009',
|
|
40
|
+
// },
|
|
41
|
+
// stage: 3,
|
|
42
|
+
// }),
|
|
43
|
+
// ],
|
|
44
|
+
//sourceMap: shouldUseSourceMap,
|
|
45
|
+
// },
|
|
46
46
|
},
|
|
47
47
|
{
|
|
48
48
|
loader: require.resolve('stylus-loader'),
|
|
@@ -57,6 +57,9 @@ const getStylusLoader = (cssOptions) => {
|
|
|
57
57
|
|
|
58
58
|
// Export a function. Accept the base config as the only param.
|
|
59
59
|
module.exports = {
|
|
60
|
+
core: {
|
|
61
|
+
builder: 'webpack5',
|
|
62
|
+
},
|
|
60
63
|
stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'],
|
|
61
64
|
addons: [
|
|
62
65
|
'@storybook/addon-links',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@woosmap/ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/WebGeoServices/ui.git"
|
|
@@ -14,20 +14,21 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@mapbox/polyline": "^1.1.1",
|
|
17
|
+
"@storybook/manager-webpack5": "^6.5.15",
|
|
17
18
|
"axios": "^0.21.1",
|
|
18
|
-
"classnames": "^2.3.
|
|
19
|
-
"framer-motion": "^
|
|
20
|
-
"google-map-react": "^2.
|
|
21
|
-
"i18next": "^
|
|
22
|
-
"moment": "^2.29.
|
|
23
|
-
"perfect-scrollbar": "^1.5.
|
|
24
|
-
"prop-types": "^15.
|
|
25
|
-
"react": "^
|
|
26
|
-
"react-datetime": "^3.0
|
|
27
|
-
"react-dom": "^
|
|
28
|
-
"react-laag": "^2.0.
|
|
29
|
-
"react-select": "^
|
|
30
|
-
"react-syntax-highlighter": "^15.
|
|
19
|
+
"classnames": "^2.3.2",
|
|
20
|
+
"framer-motion": "^8.1.9",
|
|
21
|
+
"google-map-react": "^2.2.0",
|
|
22
|
+
"i18next": "^22.4.8",
|
|
23
|
+
"moment": "^2.29.4",
|
|
24
|
+
"perfect-scrollbar": "^1.5.5",
|
|
25
|
+
"prop-types": "^15.8.1",
|
|
26
|
+
"react": "^18.2.0",
|
|
27
|
+
"react-datetime": "^3.2.0",
|
|
28
|
+
"react-dom": "^18.2.0",
|
|
29
|
+
"react-laag": "^2.0.4",
|
|
30
|
+
"react-select": "^5.7.0",
|
|
31
|
+
"react-syntax-highlighter": "^15.5.0",
|
|
31
32
|
"resize-observer-polyfill": "^1.5.1",
|
|
32
33
|
"zxcvbn": "^4.4.2"
|
|
33
34
|
},
|
|
@@ -66,33 +67,34 @@
|
|
|
66
67
|
]
|
|
67
68
|
},
|
|
68
69
|
"devDependencies": {
|
|
69
|
-
"@babel/cli": "^7.
|
|
70
|
-
"@babel/core": "^7.
|
|
71
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
72
|
-
"@storybook/addon-actions": "^6.
|
|
73
|
-
"@storybook/addon-essentials": "^6.
|
|
74
|
-
"@storybook/addon-jest": "^6.
|
|
75
|
-
"@storybook/addon-links": "^6.
|
|
76
|
-
"@storybook/
|
|
77
|
-
"@storybook/
|
|
78
|
-
"@storybook/react": "^
|
|
79
|
-
"@storybook/
|
|
80
|
-
"@
|
|
81
|
-
"@testing-library/
|
|
82
|
-
"@testing-library/
|
|
83
|
-
"
|
|
70
|
+
"@babel/cli": "^7.20.7",
|
|
71
|
+
"@babel/core": "^7.20.7",
|
|
72
|
+
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
73
|
+
"@storybook/addon-actions": "^6.5.15",
|
|
74
|
+
"@storybook/addon-essentials": "^6.5.15",
|
|
75
|
+
"@storybook/addon-jest": "^6.5.15",
|
|
76
|
+
"@storybook/addon-links": "^6.5.15",
|
|
77
|
+
"@storybook/builder-webpack5": "^6.5.15",
|
|
78
|
+
"@storybook/node-logger": "^6.5.15",
|
|
79
|
+
"@storybook/preset-create-react-app": "^4.1.2",
|
|
80
|
+
"@storybook/react": "^6.5.15",
|
|
81
|
+
"@storybook/storybook-deployer": "^2.8.16",
|
|
82
|
+
"@testing-library/jest-dom": "^5.16.5",
|
|
83
|
+
"@testing-library/react": "^13.4.0",
|
|
84
|
+
"@testing-library/user-event": "^14.4.3",
|
|
85
|
+
"babel-plugin-i18next-extract": "^0.9.0",
|
|
84
86
|
"babel-plugin-transform-dynamic-import": "^2.1.0",
|
|
85
87
|
"concurrently": "^6.2.0",
|
|
86
88
|
"eslint-config-airbnb": "^18.2.1",
|
|
87
|
-
"eslint-config-prettier": "^8.
|
|
88
|
-
"eslint-plugin-prettier": "^
|
|
89
|
-
"eslint-plugin-sonarjs": "^0.
|
|
89
|
+
"eslint-config-prettier": "^8.6.0",
|
|
90
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
91
|
+
"eslint-plugin-sonarjs": "^0.17.0",
|
|
90
92
|
"jest-google-maps-mock": "^1.0.7",
|
|
91
|
-
"prettier": "^2.
|
|
92
|
-
"react-scripts": "
|
|
93
|
+
"prettier": "^2.8.1",
|
|
94
|
+
"react-scripts": "5.0.1",
|
|
93
95
|
"rimraf": "^3.0.2",
|
|
94
|
-
"stylus": "^0.
|
|
95
|
-
"stylus-loader": "^
|
|
96
|
-
"svgo": "^
|
|
96
|
+
"stylus": "^0.59.0",
|
|
97
|
+
"stylus-loader": "^7.1.0",
|
|
98
|
+
"svgo": "^3.0.2"
|
|
97
99
|
}
|
|
98
100
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
3
|
-
import userEvent from '@testing-library/user-event';
|
|
2
|
+
import { fireEvent, render } from '@testing-library/react';
|
|
4
3
|
import '@testing-library/jest-dom/extend-expect';
|
|
5
4
|
|
|
6
5
|
import CopyClipboardButton from './CopyClipboardButton';
|
|
@@ -18,20 +17,20 @@ it('renders a CopyClipboardButton component without label', () => {
|
|
|
18
17
|
it('copies the content', () => {
|
|
19
18
|
const { container } = render(<CopyClipboardButton text="Text to be copied" />);
|
|
20
19
|
document.execCommand = jest.fn();
|
|
21
|
-
|
|
20
|
+
fireEvent.click(container.firstChild);
|
|
22
21
|
expect(document.execCommand).toHaveBeenCalledWith('copy');
|
|
23
22
|
});
|
|
24
23
|
|
|
25
24
|
it('copies the content from callback', () => {
|
|
26
25
|
const { container } = render(<CopyClipboardButton getText={() => 'Text to be copied'} />);
|
|
27
26
|
document.execCommand = jest.fn();
|
|
28
|
-
|
|
27
|
+
fireEvent.click(container.firstChild);
|
|
29
28
|
expect(document.execCommand).toHaveBeenCalledWith('copy');
|
|
30
29
|
});
|
|
31
30
|
|
|
32
31
|
it('copies the content and send a call back', () => {
|
|
33
32
|
const cb = jest.fn();
|
|
34
33
|
const { container } = render(<CopyClipboardButton text="text" copyCallback={cb} />);
|
|
35
|
-
|
|
34
|
+
fireEvent.click(container.firstChild);
|
|
36
35
|
expect(cb).toHaveBeenCalledWith();
|
|
37
36
|
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { fireEvent, render, screen } from '@testing-library/react';
|
|
3
|
-
import userEvent from '@testing-library/user-event';
|
|
4
3
|
import '@testing-library/jest-dom/extend-expect';
|
|
5
4
|
import 'resize-observer-polyfill/dist/ResizeObserver.global';
|
|
6
5
|
|
|
@@ -28,7 +27,7 @@ it('opens / closes the dropdown ', () => {
|
|
|
28
27
|
</Dropdown>
|
|
29
28
|
);
|
|
30
29
|
expect(container.firstChild).not.toHaveClass('open');
|
|
31
|
-
|
|
30
|
+
fireEvent.click(screen.getByText('My dropdown'));
|
|
32
31
|
expect(container.firstChild).toHaveClass('open');
|
|
33
32
|
});
|
|
34
33
|
|
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import { render, screen, getByRole, fireEvent } from '@testing-library/react';
|
|
3
3
|
import { act } from 'react-dom/test-utils';
|
|
4
4
|
import '@testing-library/jest-dom/extend-expect';
|
|
5
|
-
import userEvent from '@testing-library/user-event';
|
|
6
5
|
|
|
7
6
|
import DynamicTag from './DynamicTag';
|
|
8
7
|
|
|
@@ -29,7 +28,7 @@ it('remove a tag if closed', () => {
|
|
|
29
28
|
const close = getByRole(tags[0], 'button');
|
|
30
29
|
expect(close).toBeTruthy();
|
|
31
30
|
act(() => {
|
|
32
|
-
|
|
31
|
+
fireEvent.click(close);
|
|
33
32
|
});
|
|
34
33
|
expect(ref.current.getTags()).toEqual([]);
|
|
35
34
|
});
|
|
@@ -40,13 +39,13 @@ it('add a tag by clicking the OK btn', () => {
|
|
|
40
39
|
const input = screen.getByPlaceholderText('tags');
|
|
41
40
|
expect(input).toBeTruthy();
|
|
42
41
|
|
|
43
|
-
|
|
42
|
+
fireEvent.change(input, { target: { value: 'mytag' } });
|
|
44
43
|
expect(input).toHaveValue('mytag');
|
|
45
44
|
|
|
46
45
|
expect(ref.current.getTags()).toEqual([]);
|
|
47
46
|
const ok = screen.getByRole('button');
|
|
48
47
|
act(() => {
|
|
49
|
-
|
|
48
|
+
fireEvent.click(ok);
|
|
50
49
|
});
|
|
51
50
|
expect(ref.current.getTags()).toEqual(['mytag']);
|
|
52
51
|
});
|
|
@@ -57,21 +56,22 @@ it('cant add the same value twice', () => {
|
|
|
57
56
|
const input = screen.getByPlaceholderText('tags');
|
|
58
57
|
expect(input).toBeTruthy();
|
|
59
58
|
|
|
60
|
-
|
|
59
|
+
fireEvent.change(input, { target: { value: 'mytag' } });
|
|
60
|
+
|
|
61
61
|
expect(input).toHaveValue('mytag');
|
|
62
62
|
|
|
63
63
|
expect(ref.current.getTags()).toEqual([]);
|
|
64
64
|
const ok = screen.getByRole('button');
|
|
65
65
|
act(() => {
|
|
66
|
-
|
|
66
|
+
fireEvent.click(ok);
|
|
67
67
|
});
|
|
68
68
|
expect(ref.current.getTags()).toEqual(['mytag']);
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
fireEvent.change(input, { target: { value: 'mytag' } });
|
|
71
71
|
expect(input).toHaveValue('mytag');
|
|
72
72
|
|
|
73
73
|
act(() => {
|
|
74
|
-
|
|
74
|
+
fireEvent.click(ok);
|
|
75
75
|
});
|
|
76
76
|
|
|
77
77
|
expect(screen.getByTestId('input-error')).toBeVisible();
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import userEvent from '@testing-library/user-event';
|
|
2
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
4
3
|
import '@testing-library/jest-dom/extend-expect';
|
|
5
4
|
|
|
6
5
|
import InfoMessage from './InfoMessage';
|
|
@@ -19,7 +18,7 @@ it('opens a modal with the content when clicking the button ', () => {
|
|
|
19
18
|
} catch (e) {
|
|
20
19
|
// nothink
|
|
21
20
|
}
|
|
22
|
-
|
|
21
|
+
fireEvent.click(container.firstChild);
|
|
23
22
|
const modal = screen.getByTestId('info-message-modal');
|
|
24
23
|
expect(modal).toHaveClass('modal');
|
|
25
24
|
});
|
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
3
|
import '@testing-library/jest-dom/extend-expect';
|
|
4
4
|
import { act } from 'react-dom/test-utils';
|
|
5
|
-
import userEvent from '@testing-library/user-event';
|
|
6
5
|
|
|
7
6
|
import Modal from './Modal';
|
|
8
7
|
|
|
@@ -28,7 +27,7 @@ it('is hidden after clicking cancel', () => {
|
|
|
28
27
|
modalRef.current.open();
|
|
29
28
|
});
|
|
30
29
|
const cancel = screen.getByTestId('modal-cancel-button');
|
|
31
|
-
|
|
30
|
+
fireEvent.click(cancel);
|
|
32
31
|
try {
|
|
33
32
|
screen.getByTestId('modal');
|
|
34
33
|
expect('Modal displayed').toBeFalsy();
|
|
@@ -50,7 +49,7 @@ it('is hidden after clicking validate', () => {
|
|
|
50
49
|
});
|
|
51
50
|
expect(validateCb.mock.calls.length).toBe(0);
|
|
52
51
|
const validate = screen.getByTestId('modal-validate-button');
|
|
53
|
-
|
|
52
|
+
fireEvent.click(validate);
|
|
54
53
|
expect(validateCb.mock.calls.length).toBe(1);
|
|
55
54
|
});
|
|
56
55
|
|
|
@@ -5,7 +5,7 @@ export default class PasswordStrengthBar extends Component {
|
|
|
5
5
|
constructor(props) {
|
|
6
6
|
super(props);
|
|
7
7
|
this.state = {
|
|
8
|
-
score:
|
|
8
|
+
score: null,
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
|
|
@@ -44,25 +44,27 @@ export default class PasswordStrengthBar extends Component {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
return (
|
|
47
|
-
|
|
48
|
-
<div className="password-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
47
|
+
score !== null && (
|
|
48
|
+
<div className="password-strength">
|
|
49
|
+
<div className="password-strength__wrapper">
|
|
50
|
+
{[1, 2, 3, 4].map((el) => (
|
|
51
|
+
<Fragment key={`password-strength-bar-item-${el}`}>
|
|
52
|
+
{el > 1 && <div className="password-strength__space" />}
|
|
53
|
+
<div
|
|
54
|
+
className="password-strength__item"
|
|
55
|
+
data-testid={el}
|
|
56
|
+
style={{
|
|
57
|
+
backgroundColor: score >= el ? barColors[score] : barColors[0],
|
|
58
|
+
}}
|
|
59
|
+
/>
|
|
60
|
+
</Fragment>
|
|
61
|
+
))}
|
|
62
|
+
</div>
|
|
63
|
+
<p className="password-strength__desc" style={{ color: barColors[score] }}>
|
|
64
|
+
{newShortScoreWord}
|
|
65
|
+
</p>
|
|
61
66
|
</div>
|
|
62
|
-
|
|
63
|
-
{newShortScoreWord}
|
|
64
|
-
</p>
|
|
65
|
-
</div>
|
|
67
|
+
)
|
|
66
68
|
);
|
|
67
69
|
}
|
|
68
70
|
}
|
|
@@ -21,13 +21,6 @@ const green = '#25c281';
|
|
|
21
21
|
const barColors = [grey, red, orange, blue, green];
|
|
22
22
|
|
|
23
23
|
describe('PasswordStrengthBar', () => {
|
|
24
|
-
it('renders', async () => {
|
|
25
|
-
const { container } = render(<PasswordStrengthBar password="mypassword" />);
|
|
26
|
-
expect(container.firstChild).toHaveClass('password-strength');
|
|
27
|
-
|
|
28
|
-
const bar1 = await waitFor(() => screen.getByTestId('1'));
|
|
29
|
-
expect(bar1).toHaveClass('password-strength__item');
|
|
30
|
-
});
|
|
31
24
|
|
|
32
25
|
describe('Color changing / complexity', () => {
|
|
33
26
|
it('renders all bars in grey when password is too short', async () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {render, screen, waitFor} from '@testing-library/react';
|
|
3
3
|
import '@testing-library/jest-dom/extend-expect';
|
|
4
|
-
import
|
|
4
|
+
import fireEvent from '@testing-library/user-event';
|
|
5
5
|
import SnackBar from './SnackBar';
|
|
6
6
|
import withSnackBar from './withSnackBar';
|
|
7
7
|
import Button from '../Button/Button';
|
|
@@ -26,7 +26,7 @@ class SomeChildComponent extends React.Component {
|
|
|
26
26
|
|
|
27
27
|
const WithSnackBarComponent = withSnackBar(SomeChildComponent);
|
|
28
28
|
|
|
29
|
-
it('renders a Snackbar component ', () => {
|
|
29
|
+
it('renders a Snackbar component ', async () => {
|
|
30
30
|
render(
|
|
31
31
|
<SnackBar>
|
|
32
32
|
<div>
|
|
@@ -40,10 +40,10 @@ it('renders a Snackbar component ', () => {
|
|
|
40
40
|
} catch (e) {
|
|
41
41
|
// nothing
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
const snackbar = screen.getByTestId('snackbar');
|
|
43
|
+
fireEvent.click(screen.getByTestId('open'));
|
|
44
|
+
const snackbar = await waitFor(() => screen.getByTestId('snackbar'));
|
|
45
45
|
expect(snackbar).toHaveTextContent('This is the content of the Snackbar.');
|
|
46
|
-
|
|
46
|
+
fireEvent.click(screen.getByTestId('close'));
|
|
47
47
|
try {
|
|
48
48
|
screen.getByTestId('snackbar');
|
|
49
49
|
expect('SnackBar exists').toBeFalsy();
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { fireEvent, render, screen } from '@testing-library/react';
|
|
3
3
|
import '@testing-library/jest-dom/extend-expect';
|
|
4
|
-
import userEvent from '@testing-library/user-event';
|
|
5
4
|
|
|
6
5
|
import Switch from './Switch';
|
|
7
6
|
|
|
@@ -37,7 +36,7 @@ it('calls the onChange prop when clicking the label', () => {
|
|
|
37
36
|
/>
|
|
38
37
|
);
|
|
39
38
|
expect(onChange.mock.calls.length).toBe(0);
|
|
40
|
-
|
|
39
|
+
fireEvent.click(screen.getByRole('switch'));
|
|
41
40
|
expect(onChange.mock.calls.length).toBe(1);
|
|
42
41
|
});
|
|
43
42
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import userEvent from '@testing-library/user-event';
|
|
2
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
4
3
|
import '@testing-library/jest-dom/extend-expect';
|
|
5
4
|
|
|
6
5
|
import Tab from './Tab';
|
|
@@ -28,7 +27,7 @@ it('renders a tab component with 2 tabs and content', () => {
|
|
|
28
27
|
const firstTab = screen.getByText('First');
|
|
29
28
|
expect(firstTab).toHaveClass('active');
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
fireEvent.click(screen.getByText('tab 2'));
|
|
32
31
|
});
|
|
33
32
|
|
|
34
33
|
it('changes active tab after click', () => {
|
|
@@ -39,7 +38,7 @@ it('changes active tab after click', () => {
|
|
|
39
38
|
</Tab>
|
|
40
39
|
);
|
|
41
40
|
|
|
42
|
-
|
|
41
|
+
fireEvent.click(screen.getByText('tab 2'));
|
|
43
42
|
const secondTab = screen.getByText('Second');
|
|
44
43
|
expect(secondTab).toHaveClass('active');
|
|
45
44
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
3
3
|
import '@testing-library/jest-dom/extend-expect';
|
|
4
|
-
import userEvent from '@testing-library/user-event';
|
|
5
4
|
|
|
6
5
|
import withClickOutside from './withClickOutside';
|
|
7
6
|
|
|
@@ -29,8 +28,8 @@ it('renders a label component ', () => {
|
|
|
29
28
|
</>
|
|
30
29
|
);
|
|
31
30
|
expect(handleClickOutside.mock.calls.length).toBe(0);
|
|
32
|
-
|
|
31
|
+
fireEvent.mouseDown(container.firstChild);
|
|
33
32
|
expect(handleClickOutside.mock.calls.length).toBe(0);
|
|
34
|
-
|
|
33
|
+
fireEvent.mouseDown(screen.getByTestId('outside'));
|
|
35
34
|
expect(handleClickOutside.mock.calls.length).toBe(1);
|
|
36
35
|
});
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/* eslint-disable react/prop-types */
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
4
4
|
import '@testing-library/jest-dom/extend-expect';
|
|
5
|
-
import userEvent from '@testing-library/user-event';
|
|
6
5
|
import Input from '../Input/Input';
|
|
7
6
|
import Button from '../Button/Button';
|
|
8
7
|
import withFormValidation, { validationStrategy } from './withFormValidation';
|
|
@@ -42,13 +41,13 @@ it('renders a withFormValidation component ', () => {
|
|
|
42
41
|
<WrappedWithFormValidation />
|
|
43
42
|
</>
|
|
44
43
|
);
|
|
45
|
-
|
|
44
|
+
fireEvent.click(screen.getByTestId('submit'));
|
|
46
45
|
expect(screen.getByTestId('form')).toHaveTextContent('Required field');
|
|
47
46
|
});
|
|
48
47
|
|
|
49
48
|
it('validates min length', () => {
|
|
50
49
|
let error = validationStrategy('minLength', { minLength: 6 }, 'short');
|
|
51
|
-
expect(error).toEqual('Should be at least 6
|
|
50
|
+
expect(error).toEqual('Should be at least 6 char long');
|
|
52
51
|
error = validationStrategy('minLength', { minLength: 6 }, 'longvalue');
|
|
53
52
|
expect(error).toBeFalsy();
|
|
54
53
|
});
|
|
@@ -57,7 +56,7 @@ it('validates max length', () => {
|
|
|
57
56
|
let error = validationStrategy('maxLength', { maxLength: 6 }, 'short');
|
|
58
57
|
expect(error).toBeFalsy();
|
|
59
58
|
error = validationStrategy('maxLength', { maxLength: 6 }, 'tooolong');
|
|
60
|
-
expect(error).toEqual('Should be at most 6
|
|
59
|
+
expect(error).toEqual('Should be at most 6 char long');
|
|
61
60
|
});
|
|
62
61
|
|
|
63
62
|
it('validates required', () => {
|