@woosmap/ui 4.229.0 → 4.230.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@woosmap/ui",
3
- "version": "4.229.0",
3
+ "version": "4.230.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/WebGeoServices/ui.git"
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { act } from 'react';
2
2
  import { fireEvent, render, screen, waitFor } from '@testing-library/react';
3
3
  import '@testing-library/jest-dom/extend-expect';
4
4
 
@@ -27,28 +27,36 @@ it('render distance demo', () => {
27
27
  it('test transport button', () => {
28
28
  render(<DistanceDemo />);
29
29
  expect(screen.getByText('mode=driving&\\')).toBeVisible();
30
- fireEvent.click(screen.getByAltText('Cycling'));
30
+ act(() => {
31
+ fireEvent.click(screen.getByAltText('Cycling'));
32
+ });
31
33
  expect(screen.getByText('mode=cycling&\\')).toBeVisible();
32
34
  });
33
35
 
34
36
  it('test metrics button', () => {
35
37
  render(<DistanceDemo />);
36
38
  expect(screen.getByText('units=metric&\\')).toBeVisible();
37
- fireEvent.click(screen.getByLabelText('Imperial'));
39
+ act(() => {
40
+ fireEvent.click(screen.getByText('Imperial'));
41
+ });
38
42
  expect(screen.getByText('units=imperial&\\')).toBeVisible();
39
43
  });
40
44
 
41
45
  it('test method button', () => {
42
46
  render(<DistanceDemo />);
43
47
  expect(screen.getByText('method=distance&\\')).toBeVisible();
44
- fireEvent.click(screen.getByLabelText('Fastest'));
48
+ act(() => {
49
+ fireEvent.click(screen.getByText('Fastest'));
50
+ });
45
51
  expect(screen.getByText('method=time&\\')).toBeVisible();
46
52
  });
47
53
 
48
54
  it('test language button', () => {
49
55
  render(<DistanceDemo />);
50
56
  expect(screen.getByText('language=en&\\')).toBeVisible();
51
- fireEvent.click(screen.getByTitle('Italian'));
57
+ act(() => {
58
+ fireEvent.click(screen.getByTitle('Italian'));
59
+ });
52
60
  expect(screen.getByText('language=it&\\')).toBeVisible();
53
61
  });
54
62
 
@@ -56,7 +64,9 @@ it('test alternative route checkbox', () => {
56
64
  render(<DistanceDemo />);
57
65
  expect(screen.getByText('alternatives=false"')).toBeVisible();
58
66
  const [checkbox] = screen.getByText('Alternative routes').parentElement.querySelectorAll('input');
59
- fireEvent.click(checkbox);
67
+ act(() => {
68
+ fireEvent.click(checkbox);
69
+ });
60
70
  expect(screen.getByText('alternatives=true"')).toBeVisible();
61
71
  });
62
72
 
@@ -35,7 +35,7 @@ it('calls navigator.clipboard.writeText function when click on copy button if if
35
35
  id="skeleton-test"
36
36
  />,
37
37
  );
38
- fireEvent.click(screen.getByLabelText('Copy'));
38
+ fireEvent.click(screen.getByText('Copy'));
39
39
  expect(navigator.clipboard.writeText).toHaveBeenCalledWith(
40
40
  'curl "https://api.woosmap.com/localities/autocomplete/?input=paris"',
41
41
  );
@@ -45,7 +45,7 @@ it('calls navigator.clipboard.writeText function when click on copy button if if
45
45
  it('calls copy exec command when click on copy button if navigator.clipboard not supported', () => {
46
46
  render(<SkeletonDemo noheader id="skeleton-test" />);
47
47
  document.execCommand = jest.fn();
48
- fireEvent.click(screen.getByLabelText('Copy'));
48
+ fireEvent.click(screen.getByText('Copy'));
49
49
  expect(document.execCommand).toHaveBeenCalledWith('copy');
50
50
  });
51
51
 
@@ -1,9 +1,8 @@
1
- import React from 'react';
1
+ import React, { act } from 'react';
2
2
  import { fireEvent, render, screen } from '@testing-library/react';
3
3
  import '@testing-library/jest-dom/extend-expect';
4
4
  import 'resize-observer-polyfill/dist/ResizeObserver.global';
5
5
 
6
- import { act } from 'react-dom/test-utils';
7
6
  import Dropdown from './Dropdown';
8
7
 
9
8
  it('renders a Dropdown component ', () => {
@@ -1,6 +1,5 @@
1
- import React from 'react';
1
+ import React, { act } from 'react';
2
2
  import { render, screen, getByRole, fireEvent } from '@testing-library/react';
3
- import { act } from 'react-dom/test-utils';
4
3
  import '@testing-library/jest-dom/extend-expect';
5
4
 
6
5
  import DynamicTag from './DynamicTag';
@@ -9,7 +9,7 @@ export default class Input extends Component {
9
9
  super(props);
10
10
  this.inputId = uniqueId();
11
11
  this.inputRef = React.createRef();
12
- this.state = { showPassword: false, value: null };
12
+ this.state = { showPassword: false, value: '' };
13
13
  }
14
14
 
15
15
  componentDidMount() {
@@ -146,7 +146,7 @@ export default class Input extends Component {
146
146
  onFocus,
147
147
  onKeyDown: this.onKeyDown,
148
148
  type: type === 'password' && showPassword ? 'text' : type,
149
- value: value !== undefined ? value : stateValue,
149
+ value: value !== undefined ? value : stateValue || '',
150
150
  size: length,
151
151
  disabled,
152
152
  onChange: this.onChange,
@@ -172,7 +172,7 @@ export default class Input extends Component {
172
172
  <Icon
173
173
  icon={showPassword ? 'eye-crossed-out' : 'eye'}
174
174
  size={iconSize}
175
- className={{ showed: showPassword }}
175
+ className={showPassword ? 'showed' : ''}
176
176
  />
177
177
  </span>
178
178
  )}
@@ -1,7 +1,6 @@
1
- import React from 'react';
1
+ import React, { act } from 'react';
2
2
  import { render, screen, fireEvent } from '@testing-library/react';
3
3
  import '@testing-library/jest-dom/extend-expect';
4
- import { act } from 'react-dom/test-utils';
5
4
 
6
5
  import Modal from './Modal';
7
6
 
@@ -1,7 +1,6 @@
1
- import React from 'react';
1
+ import React, { act } from 'react';
2
2
  import { render, screen } from '@testing-library/react';
3
3
  import '@testing-library/jest-dom/extend-expect';
4
- import { act } from 'react-dom/test-utils';
5
4
  import userEvent from '@testing-library/user-event';
6
5
 
7
6
  import Panel from './Panel';
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { act } from 'react';
2
2
  import { render } from '@testing-library/react';
3
3
  import '@testing-library/jest-dom/extend-expect';
4
4
 
@@ -23,23 +23,33 @@ const barColors = [grey, red, orange, blue, green];
23
23
  describe('PasswordStrengthBar', () => {
24
24
  describe('Color changing / complexity', () => {
25
25
  it('renders all bars in grey when password is too short', async () => {
26
- render(<PasswordStrengthBar password={password.tooShort} barColors={barColors} />);
26
+ act(() => {
27
+ render(<PasswordStrengthBar password={password.tooShort} barColors={barColors} />);
28
+ });
27
29
  });
28
30
 
29
31
  it('renders the first bar in red and the others in grey when password is weak', async () => {
30
- render(<PasswordStrengthBar password={password.weak} barColors={barColors} />);
32
+ act(() => {
33
+ render(<PasswordStrengthBar password={password.weak} barColors={barColors} />);
34
+ });
31
35
  });
32
36
 
33
37
  it('renders the two first bars in orange and others in grey when password is okay', async () => {
34
- render(<PasswordStrengthBar password={password.okay} barColors={barColors} />);
38
+ act(() => {
39
+ render(<PasswordStrengthBar password={password.okay} barColors={barColors} />);
40
+ });
35
41
  });
36
42
 
37
43
  it('renders the three first bars in blue and the last in grey when password is good', async () => {
38
- render(<PasswordStrengthBar password={password.good} barColors={barColors} />);
44
+ act(() => {
45
+ render(<PasswordStrengthBar password={password.good} barColors={barColors} />);
46
+ });
39
47
  });
40
48
 
41
49
  it('renders all bars in green when password is strong', async () => {
42
- render(<PasswordStrengthBar password={password.strong} barColors={barColors} />);
50
+ act(() => {
51
+ render(<PasswordStrengthBar password={password.strong} barColors={barColors} />);
52
+ });
43
53
  });
44
54
  });
45
55
  });
@@ -65,11 +65,17 @@ Popover.defaultProps = {
65
65
 
66
66
  function withLayer(MyComponent) {
67
67
  function WrappedComponent(props) {
68
+ const {
69
+ forwardedRef,
70
+ container = null,
71
+ placement = 'bottom-center',
72
+ disableClickOutside = false,
73
+ ...rest
74
+ } = props;
68
75
  const [isOpen, setOpen] = React.useState(false);
69
76
  function close() {
70
77
  setOpen(false);
71
78
  }
72
- const { forwardedRef, container, placement, disableClickOutside, ...rest } = props;
73
79
  const { renderLayer, triggerProps, layerProps, arrowProps } = useLayer({
74
80
  isOpen,
75
81
  container,
@@ -95,17 +101,17 @@ function withLayer(MyComponent) {
95
101
  />
96
102
  );
97
103
  }
98
- WrappedComponent.defaultProps = {
99
- container: null,
100
- placement: 'bottom-center',
101
- disableClickOutside: false,
102
- };
103
104
  WrappedComponent.propTypes = {
104
105
  forwardedRef: PropTypes.object.isRequired,
105
106
  container: PropTypes.string,
106
107
  placement: PropTypes.string,
107
108
  disableClickOutside: PropTypes.bool,
108
109
  };
110
+ WrappedComponent.defaultProps = {
111
+ container: null,
112
+ placement: 'bottom-center',
113
+ disableClickOutside: false,
114
+ };
109
115
  return React.forwardRef((props, ref) => <WrappedComponent {...props} forwardedRef={ref} />);
110
116
  }
111
117
 
@@ -1,7 +1,6 @@
1
- import React from 'react';
1
+ import React, { act } from 'react';
2
2
  import { render, screen } from '@testing-library/react';
3
3
  import '@testing-library/jest-dom/extend-expect';
4
- import { act } from 'react-dom/test-utils';
5
4
 
6
5
  import Button from '../Button/Button';
7
6
  import Popover from './Popover';
@@ -32,11 +31,13 @@ it('renders a Popover component ', () => {
32
31
  it('Button click should make it visible', () => {
33
32
  const ref = React.createRef();
34
33
  const testId = 'popover-content';
35
- render(
36
- <Popover content="My popover" ref={ref}>
37
- <Button onClick={() => {}} label="my button" />
38
- </Popover>,
39
- );
34
+ act(() => {
35
+ render(
36
+ <Popover content="My popover" ref={ref}>
37
+ <Button onClick={() => {}} label="my button" />
38
+ </Popover>,
39
+ );
40
+ });
40
41
  try {
41
42
  screen.getByTestId(testId);
42
43
  expect('Popover displayed').toBeFalsy();
@@ -1,6 +1,5 @@
1
- import React from 'react';
1
+ import React, { act } from 'react';
2
2
  import { render } from '@testing-library/react';
3
- import { act } from 'react-dom/test-utils';
4
3
  import '@testing-library/jest-dom/extend-expect';
5
4
  import ServiceMessage from './ServiceMessage';
6
5
 
@@ -41,7 +41,7 @@ it('renders a withFormValidation component ', () => {
41
41
 
42
42
  it('validates min length', () => {
43
43
  let error = validationStrategy('minLength', { minLength: 6 }, 'short');
44
- expect(error).toEqual('Should be at least 6 char long');
44
+ expect(error).toEqual('Should be at least 6 char long__plural');
45
45
  error = validationStrategy('minLength', { minLength: 6 }, 'longvalue');
46
46
  expect(error).toBeFalsy();
47
47
  });
@@ -50,7 +50,7 @@ it('validates max length', () => {
50
50
  let error = validationStrategy('maxLength', { maxLength: 6 }, 'short');
51
51
  expect(error).toBeFalsy();
52
52
  error = validationStrategy('maxLength', { maxLength: 6 }, 'tooolong');
53
- expect(error).toEqual('Should be at most 6 char long');
53
+ expect(error).toEqual('Should be at most 6 char long__plural');
54
54
  });
55
55
 
56
56
  it('validates required', () => {