@woosmap/ui 3.183.0 → 3.185.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.
Files changed (28) hide show
  1. package/.storybook/main.js +13 -16
  2. package/package.json +37 -39
  3. package/src/components/CopyClipboardButton/CopyToClipboard.test.js +5 -4
  4. package/src/components/Demo/GeolocationDemo.js +0 -1
  5. package/src/components/Demo/LocalitiesAllDemo.js +0 -1
  6. package/src/components/Demo/LocalitiesDemo.js +0 -1
  7. package/src/components/Demo/LocalitiesFRAddressDemo.js +1 -1
  8. package/src/components/Demo/LocalitiesUKAddressDemo.js +1 -1
  9. package/src/components/Demo/MapDemo.js +1 -1
  10. package/src/components/Demo/MerchantDemo.js +0 -1
  11. package/src/components/Dropdown/Dropdown.test.js +2 -1
  12. package/src/components/DynamicTag/DynamicTag.stories.js +0 -4
  13. package/src/components/DynamicTag/DynamicTag.test.js +8 -8
  14. package/src/components/Icon/Icon.js +2 -0
  15. package/src/components/InfoMessage/InfoMessage.stories.js +0 -1
  16. package/src/components/InfoMessage/InfoMessage.test.js +3 -2
  17. package/src/components/Modal/Modal.test.js +3 -2
  18. package/src/components/Panel/Panel.js +0 -1
  19. package/src/components/PasswordStrengthBar/PasswordStrengthBar.js +19 -21
  20. package/src/components/PasswordStrengthBar/PasswordStrengthBar.stories.js +0 -4
  21. package/src/components/PasswordStrengthBar/PasswordStrengthBar.test.js +7 -0
  22. package/src/components/Select/Select.js +0 -1
  23. package/src/components/SnackBar/SnackBar.test.js +6 -6
  24. package/src/components/Switch/Switch.test.js +2 -1
  25. package/src/components/Tab/Tab.stories.js +0 -1
  26. package/src/components/Tab/Tab.test.js +4 -3
  27. package/src/components/withClickOutside/withClickOutside.test.js +4 -3
  28. package/src/components/withFormValidation/withFormValidation.test.js +5 -4
@@ -30,19 +30,19 @@ const getStylusLoader = (cssOptions) => {
30
30
  },
31
31
  {
32
32
  loader: require.resolve('postcss-loader'),
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
- // },
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,9 +57,6 @@ 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
- },
63
60
  stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'],
64
61
  addons: [
65
62
  '@storybook/addon-links',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@woosmap/ui",
3
- "version": "3.183.0",
3
+ "version": "3.185.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/WebGeoServices/ui.git"
@@ -13,21 +13,20 @@
13
13
  },
14
14
  "dependencies": {
15
15
  "@mapbox/polyline": "^1.1.1",
16
- "@storybook/manager-webpack5": "^6.5.15",
17
16
  "axios": "^0.21.1",
18
- "classnames": "^2.3.2",
19
- "framer-motion": "^8.1.9",
20
- "google-map-react": "^2.2.0",
21
- "i18next": "^22.4.8",
22
- "moment": "^2.29.4",
23
- "perfect-scrollbar": "^1.5.5",
24
- "prop-types": "^15.8.1",
25
- "react": "^18.2.0",
26
- "react-datetime": "^3.2.0",
27
- "react-dom": "^18.2.0",
28
- "react-laag": "^2.0.4",
29
- "react-select": "^5.7.0",
30
- "react-syntax-highlighter": "^15.5.0",
17
+ "classnames": "^2.3.1",
18
+ "framer-motion": "^4.1.17",
19
+ "google-map-react": "^2.1.10",
20
+ "i18next": "^20.3.5",
21
+ "moment": "^2.29.1",
22
+ "perfect-scrollbar": "^1.5.2",
23
+ "prop-types": "^15.7.2",
24
+ "react": "^17.0.2",
25
+ "react-datetime": "^3.0.4",
26
+ "react-dom": "^17.0.2",
27
+ "react-laag": "^2.0.3",
28
+ "react-select": "^4.3.1",
29
+ "react-syntax-highlighter": "^15.4.4",
31
30
  "resize-observer-polyfill": "^1.5.1",
32
31
  "zxcvbn": "^4.4.2"
33
32
  },
@@ -66,34 +65,33 @@
66
65
  ]
67
66
  },
68
67
  "devDependencies": {
69
- "@babel/cli": "^7.20.7",
70
- "@babel/core": "^7.20.7",
71
- "@babel/plugin-proposal-class-properties": "^7.18.6",
72
- "@storybook/addon-actions": "^6.5.15",
73
- "@storybook/addon-essentials": "^6.5.15",
74
- "@storybook/addon-jest": "^6.5.15",
75
- "@storybook/addon-links": "^6.5.15",
76
- "@storybook/builder-webpack5": "^6.5.15",
77
- "@storybook/node-logger": "^6.5.15",
78
- "@storybook/preset-create-react-app": "^4.1.2",
79
- "@storybook/react": "^6.5.15",
80
- "@storybook/storybook-deployer": "^2.8.16",
81
- "@testing-library/jest-dom": "^5.16.5",
82
- "@testing-library/react": "^13.4.0",
83
- "@testing-library/user-event": "^14.4.3",
84
- "babel-plugin-i18next-extract": "^0.9.0",
68
+ "@babel/cli": "^7.14.8",
69
+ "@babel/core": "^7.14.8",
70
+ "@babel/plugin-proposal-class-properties": "^7.14.5",
71
+ "@storybook/addon-actions": "^6.3.6",
72
+ "@storybook/addon-essentials": "^6.3.6",
73
+ "@storybook/addon-jest": "^6.3.6",
74
+ "@storybook/addon-links": "^6.3.6",
75
+ "@storybook/node-logger": "^6.3.6",
76
+ "@storybook/preset-create-react-app": "^3.2.0",
77
+ "@storybook/react": "^6.3.6",
78
+ "@storybook/storybook-deployer": "^2.8.10",
79
+ "@testing-library/jest-dom": "^5.14.1",
80
+ "@testing-library/react": "^11.2.7",
81
+ "@testing-library/user-event": "^12.8.3",
82
+ "babel-plugin-i18next-extract": "^0.8.3",
85
83
  "babel-plugin-transform-dynamic-import": "^2.1.0",
86
84
  "concurrently": "^6.2.0",
87
85
  "eslint-config-airbnb": "^18.2.1",
88
- "eslint-config-prettier": "^8.6.0",
89
- "eslint-plugin-prettier": "^4.2.1",
90
- "eslint-plugin-sonarjs": "^0.17.0",
86
+ "eslint-config-prettier": "^8.3.0",
87
+ "eslint-plugin-prettier": "^3.4.0",
88
+ "eslint-plugin-sonarjs": "^0.9.1",
91
89
  "jest-google-maps-mock": "^1.0.7",
92
- "prettier": "^2.8.1",
93
- "react-scripts": "5.0.1",
90
+ "prettier": "^2.3.2",
91
+ "react-scripts": "4.0.3",
94
92
  "rimraf": "^3.0.2",
95
- "stylus": "^0.59.0",
96
- "stylus-loader": "^7.1.0",
97
- "svgo": "^3.0.2"
93
+ "stylus": "^0.54.8",
94
+ "stylus-loader": "^4.3.3",
95
+ "svgo": "^2.3.1"
98
96
  }
99
97
  }
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import { fireEvent, render } from '@testing-library/react';
2
+ import { render } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
3
4
  import '@testing-library/jest-dom/extend-expect';
4
5
 
5
6
  import CopyClipboardButton from './CopyClipboardButton';
@@ -17,20 +18,20 @@ it('renders a CopyClipboardButton component without label', () => {
17
18
  it('copies the content', () => {
18
19
  const { container } = render(<CopyClipboardButton text="Text to be copied" />);
19
20
  document.execCommand = jest.fn();
20
- fireEvent.click(container.firstChild);
21
+ userEvent.click(container.firstChild);
21
22
  expect(document.execCommand).toHaveBeenCalledWith('copy');
22
23
  });
23
24
 
24
25
  it('copies the content from callback', () => {
25
26
  const { container } = render(<CopyClipboardButton getText={() => 'Text to be copied'} />);
26
27
  document.execCommand = jest.fn();
27
- fireEvent.click(container.firstChild);
28
+ userEvent.click(container.firstChild);
28
29
  expect(document.execCommand).toHaveBeenCalledWith('copy');
29
30
  });
30
31
 
31
32
  it('copies the content and send a call back', () => {
32
33
  const cb = jest.fn();
33
34
  const { container } = render(<CopyClipboardButton text="text" copyCallback={cb} />);
34
- fireEvent.click(container.firstChild);
35
+ userEvent.click(container.firstChild);
35
36
  expect(cb).toHaveBeenCalledWith();
36
37
  });
@@ -52,7 +52,6 @@ export default class GeolocationDemo extends Component {
52
52
  });
53
53
  };
54
54
 
55
- // eslint-disable-next-line class-methods-use-this
56
55
  getRequestparams = () => ({
57
56
  key: Constants.geolocationWoosmapSearchKey,
58
57
  radius: 200000,
@@ -12,7 +12,6 @@ export default class LocalitiesAllDemo extends Component {
12
12
  this.state = { usecase: 'localities' };
13
13
  }
14
14
 
15
- // eslint-disable-next-line class-methods-use-this
16
15
  renderSubHeader = () => (
17
16
  <p>
18
17
  {tr('You can select bewteen 2 use cases:')}
@@ -145,7 +145,6 @@ export default class LocalitiesDemo extends Component {
145
145
  }
146
146
  };
147
147
 
148
- // eslint-disable-next-line class-methods-use-this
149
148
  getHighlightedLocalityDesc = (locality) => {
150
149
  let { description } = locality;
151
150
 
@@ -1,4 +1,4 @@
1
- /* eslint-disable */
1
+ /* eslint-disable jsx-a11y/click-events-have-key-events */
2
2
  import axios from 'axios';
3
3
  import React, { Component } from 'react';
4
4
  import Demo from './SkeletonDemo';
@@ -1,4 +1,4 @@
1
- /* eslint-disable */
1
+ /* eslint-disable jsx-a11y/click-events-have-key-events */
2
2
  import axios from 'axios';
3
3
  import React, { Component } from 'react';
4
4
  import Demo from './SkeletonDemo';
@@ -1,4 +1,4 @@
1
- /* eslint-disable */
1
+ /* eslint-disable jsx-a11y/click-events-have-key-events */
2
2
  import React, { Component } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import Demo from './SkeletonDemo';
@@ -253,7 +253,6 @@ export default class MerchantDemo extends Component {
253
253
  this.setState({ transaction, place: {} });
254
254
  };
255
255
 
256
- // eslint-disable-next-line class-methods-use-this
257
256
  getRequestparams = () => ({
258
257
  private_key: '{your private key}',
259
258
  });
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { fireEvent, render, screen } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
3
4
  import '@testing-library/jest-dom/extend-expect';
4
5
  import 'resize-observer-polyfill/dist/ResizeObserver.global';
5
6
 
@@ -27,7 +28,7 @@ it('opens / closes the dropdown ', () => {
27
28
  </Dropdown>
28
29
  );
29
30
  expect(container.firstChild).not.toHaveClass('open');
30
- fireEvent.click(screen.getByText('My dropdown'));
31
+ userEvent.click(screen.getByText('My dropdown'));
31
32
  expect(container.firstChild).toHaveClass('open');
32
33
  });
33
34
 
@@ -45,7 +45,3 @@ export const Default = Template.bind({});
45
45
  Default.args = {
46
46
  isSelector: false,
47
47
  };
48
-
49
- Default.parameters = {
50
- jest: ['DynamicTag.test.js'],
51
- };
@@ -2,6 +2,7 @@ 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';
5
6
 
6
7
  import DynamicTag from './DynamicTag';
7
8
 
@@ -28,7 +29,7 @@ it('remove a tag if closed', () => {
28
29
  const close = getByRole(tags[0], 'button');
29
30
  expect(close).toBeTruthy();
30
31
  act(() => {
31
- fireEvent.click(close);
32
+ userEvent.click(close);
32
33
  });
33
34
  expect(ref.current.getTags()).toEqual([]);
34
35
  });
@@ -39,13 +40,13 @@ it('add a tag by clicking the OK btn', () => {
39
40
  const input = screen.getByPlaceholderText('tags');
40
41
  expect(input).toBeTruthy();
41
42
 
42
- fireEvent.change(input, { target: { value: 'mytag' } });
43
+ userEvent.type(input, 'mytag');
43
44
  expect(input).toHaveValue('mytag');
44
45
 
45
46
  expect(ref.current.getTags()).toEqual([]);
46
47
  const ok = screen.getByRole('button');
47
48
  act(() => {
48
- fireEvent.click(ok);
49
+ userEvent.click(ok);
49
50
  });
50
51
  expect(ref.current.getTags()).toEqual(['mytag']);
51
52
  });
@@ -56,22 +57,21 @@ it('cant add the same value twice', () => {
56
57
  const input = screen.getByPlaceholderText('tags');
57
58
  expect(input).toBeTruthy();
58
59
 
59
- fireEvent.change(input, { target: { value: 'mytag' } });
60
-
60
+ userEvent.type(input, 'mytag');
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
- fireEvent.click(ok);
66
+ userEvent.click(ok);
67
67
  });
68
68
  expect(ref.current.getTags()).toEqual(['mytag']);
69
69
 
70
- fireEvent.change(input, { target: { value: 'mytag' } });
70
+ userEvent.type(input, 'mytag');
71
71
  expect(input).toHaveValue('mytag');
72
72
 
73
73
  act(() => {
74
- fireEvent.click(ok);
74
+ userEvent.click(ok);
75
75
  });
76
76
 
77
77
  expect(screen.getByTestId('input-error')).toBeVisible();
@@ -6,6 +6,7 @@ import { ReactComponent as AutocompleteCheck } from '../../icons/autocomplete-ch
6
6
  import { ReactComponent as Buildings } from '../../icons/buildings.svg';
7
7
  import { ReactComponent as Battery } from '../../icons/battery.svg';
8
8
  import { ReactComponent as Blog } from '../../icons/blog.svg';
9
+ import { ReactComponent as MarkerPng } from '../../images/marker.png';
9
10
  import { ReactComponent as Book } from '../../icons/book.svg';
10
11
  import { ReactComponent as Calendar } from '../../icons/calendar.svg';
11
12
  import { ReactComponent as Care } from '../../icons/care.svg';
@@ -538,6 +539,7 @@ const ConsoleIcons = {
538
539
  longitude: Longitude,
539
540
  manage: Manage,
540
541
  marker: Marker,
542
+ markerPng: MarkerPng,
541
543
  member: Member,
542
544
  members: Members,
543
545
  'menu-circle-horizontal': MenuCircleHorizontal,
@@ -1,4 +1,3 @@
1
- /* eslint-disable */
2
1
  import React from 'react';
3
2
  import InfoMessage from './InfoMessage';
4
3
 
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import { render, screen, fireEvent } from '@testing-library/react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
3
4
  import '@testing-library/jest-dom/extend-expect';
4
5
 
5
6
  import InfoMessage from './InfoMessage';
@@ -18,7 +19,7 @@ it('opens a modal with the content when clicking the button ', () => {
18
19
  } catch (e) {
19
20
  // nothink
20
21
  }
21
- fireEvent.click(container.firstChild);
22
+ userEvent.click(container.firstChild);
22
23
  const modal = screen.getByTestId('info-message-modal');
23
24
  expect(modal).toHaveClass('modal');
24
25
  });
@@ -2,6 +2,7 @@ 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';
5
6
 
6
7
  import Modal from './Modal';
7
8
 
@@ -27,7 +28,7 @@ it('is hidden after clicking cancel', () => {
27
28
  modalRef.current.open();
28
29
  });
29
30
  const cancel = screen.getByTestId('modal-cancel-button');
30
- fireEvent.click(cancel);
31
+ userEvent.click(cancel);
31
32
  try {
32
33
  screen.getByTestId('modal');
33
34
  expect('Modal displayed').toBeFalsy();
@@ -49,7 +50,7 @@ it('is hidden after clicking validate', () => {
49
50
  });
50
51
  expect(validateCb.mock.calls.length).toBe(0);
51
52
  const validate = screen.getByTestId('modal-validate-button');
52
- fireEvent.click(validate);
53
+ userEvent.click(validate);
53
54
  expect(validateCb.mock.calls.length).toBe(1);
54
55
  });
55
56
 
@@ -85,7 +85,6 @@ class Panel extends Component {
85
85
  );
86
86
  };
87
87
 
88
- // eslint-disable-next-line class-methods-use-this
89
88
  getPlaceholderHeader = () => <span className="panel__header__fake-action" />;
90
89
 
91
90
  render() {
@@ -5,7 +5,7 @@ export default class PasswordStrengthBar extends Component {
5
5
  constructor(props) {
6
6
  super(props);
7
7
  this.state = {
8
- score: null,
8
+ score: 0,
9
9
  };
10
10
  }
11
11
 
@@ -44,27 +44,25 @@ export default class PasswordStrengthBar extends Component {
44
44
  }
45
45
 
46
46
  return (
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>
47
+ <div className="password-strength">
48
+ <div className="password-strength__wrapper">
49
+ {[1, 2, 3, 4].map((el) => (
50
+ <Fragment key={`password-strength-bar-item-${el}`}>
51
+ {el > 1 && <div className="password-strength__space" />}
52
+ <div
53
+ className="password-strength__item"
54
+ data-testid={el}
55
+ style={{
56
+ backgroundColor: score >= el ? barColors[score] : barColors[0],
57
+ }}
58
+ />
59
+ </Fragment>
60
+ ))}
66
61
  </div>
67
- )
62
+ <p className="password-strength__desc" style={{ color: barColors[score] }}>
63
+ {newShortScoreWord}
64
+ </p>
65
+ </div>
68
66
  );
69
67
  }
70
68
  }
@@ -20,7 +20,3 @@ export const Default = Template.bind({});
20
20
  Default.args = {
21
21
  password: 'mypassword',
22
22
  };
23
-
24
- Default.parameters = {
25
- jest: ['PasswordStrengthBar.test.js'],
26
- };
@@ -21,6 +21,13 @@ 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
+ });
24
31
 
25
32
  describe('Color changing / complexity', () => {
26
33
  it('renders all bars in grey when password is too short', async () => {
@@ -9,7 +9,6 @@ import CreatableSelect from 'react-select/creatable';
9
9
  *
10
10
  */
11
11
  export default class Select extends Component {
12
- // eslint-disable-next-line class-methods-use-this
13
12
  renderInput = (props) => {
14
13
  const { error, isCreatable, color, ...rest } = props;
15
14
 
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
- import {render, screen, waitFor} from '@testing-library/react';
2
+ import { render, screen } from '@testing-library/react';
3
3
  import '@testing-library/jest-dom/extend-expect';
4
- import fireEvent from '@testing-library/user-event';
4
+ import userEvent 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 ', async () => {
29
+ it('renders a Snackbar component ', () => {
30
30
  render(
31
31
  <SnackBar>
32
32
  <div>
@@ -40,10 +40,10 @@ it('renders a Snackbar component ', async () => {
40
40
  } catch (e) {
41
41
  // nothing
42
42
  }
43
- fireEvent.click(screen.getByTestId('open'));
44
- const snackbar = await waitFor(() => screen.getByTestId('snackbar'));
43
+ userEvent.click(screen.getByTestId('open'));
44
+ const snackbar = screen.getByTestId('snackbar');
45
45
  expect(snackbar).toHaveTextContent('This is the content of the Snackbar.');
46
- fireEvent.click(screen.getByTestId('close'));
46
+ userEvent.click(screen.getByTestId('close'));
47
47
  try {
48
48
  screen.getByTestId('snackbar');
49
49
  expect('SnackBar exists').toBeFalsy();
@@ -1,6 +1,7 @@
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';
4
5
 
5
6
  import Switch from './Switch';
6
7
 
@@ -36,7 +37,7 @@ it('calls the onChange prop when clicking the label', () => {
36
37
  />
37
38
  );
38
39
  expect(onChange.mock.calls.length).toBe(0);
39
- fireEvent.click(screen.getByRole('switch'));
40
+ userEvent.click(screen.getByRole('switch'));
40
41
  expect(onChange.mock.calls.length).toBe(1);
41
42
  });
42
43
 
@@ -1,4 +1,3 @@
1
- /* eslint-disable */
2
1
  import React from 'react';
3
2
  import Tab from './Tab';
4
3
 
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import { render, screen, fireEvent } from '@testing-library/react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
3
4
  import '@testing-library/jest-dom/extend-expect';
4
5
 
5
6
  import Tab from './Tab';
@@ -27,7 +28,7 @@ it('renders a tab component with 2 tabs and content', () => {
27
28
  const firstTab = screen.getByText('First');
28
29
  expect(firstTab).toHaveClass('active');
29
30
 
30
- fireEvent.click(screen.getByText('tab 2'));
31
+ userEvent.click(screen.getByText('tab 2'));
31
32
  });
32
33
 
33
34
  it('changes active tab after click', () => {
@@ -38,7 +39,7 @@ it('changes active tab after click', () => {
38
39
  </Tab>
39
40
  );
40
41
 
41
- fireEvent.click(screen.getByText('tab 2'));
42
+ userEvent.click(screen.getByText('tab 2'));
42
43
  const secondTab = screen.getByText('Second');
43
44
  expect(secondTab).toHaveClass('active');
44
45
  });
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
- import { fireEvent, render, screen } from '@testing-library/react';
2
+ import { render, screen } from '@testing-library/react';
3
3
  import '@testing-library/jest-dom/extend-expect';
4
+ import userEvent from '@testing-library/user-event';
4
5
 
5
6
  import withClickOutside from './withClickOutside';
6
7
 
@@ -28,8 +29,8 @@ it('renders a label component ', () => {
28
29
  </>
29
30
  );
30
31
  expect(handleClickOutside.mock.calls.length).toBe(0);
31
- fireEvent.mouseDown(container.firstChild);
32
+ userEvent.click(container.firstChild);
32
33
  expect(handleClickOutside.mock.calls.length).toBe(0);
33
- fireEvent.mouseDown(screen.getByTestId('outside'));
34
+ userEvent.click(screen.getByTestId('outside'));
34
35
  expect(handleClickOutside.mock.calls.length).toBe(1);
35
36
  });
@@ -1,7 +1,8 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  import React from 'react';
3
- import { render, screen, fireEvent } from '@testing-library/react';
3
+ import { render, screen } from '@testing-library/react';
4
4
  import '@testing-library/jest-dom/extend-expect';
5
+ import userEvent from '@testing-library/user-event';
5
6
  import Input from '../Input/Input';
6
7
  import Button from '../Button/Button';
7
8
  import withFormValidation, { validationStrategy } from './withFormValidation';
@@ -41,13 +42,13 @@ it('renders a withFormValidation component ', () => {
41
42
  <WrappedWithFormValidation />
42
43
  </>
43
44
  );
44
- fireEvent.click(screen.getByTestId('submit'));
45
+ userEvent.click(screen.getByTestId('submit'));
45
46
  expect(screen.getByTestId('form')).toHaveTextContent('Required field');
46
47
  });
47
48
 
48
49
  it('validates min length', () => {
49
50
  let error = validationStrategy('minLength', { minLength: 6 }, 'short');
50
- expect(error).toEqual('Should be at least 6 char long');
51
+ expect(error).toEqual('Should be at least 6 chars long');
51
52
  error = validationStrategy('minLength', { minLength: 6 }, 'longvalue');
52
53
  expect(error).toBeFalsy();
53
54
  });
@@ -56,7 +57,7 @@ it('validates max length', () => {
56
57
  let error = validationStrategy('maxLength', { maxLength: 6 }, 'short');
57
58
  expect(error).toBeFalsy();
58
59
  error = validationStrategy('maxLength', { maxLength: 6 }, 'tooolong');
59
- expect(error).toEqual('Should be at most 6 char long');
60
+ expect(error).toEqual('Should be at most 6 chars long');
60
61
  });
61
62
 
62
63
  it('validates required', () => {