@transferwise/components 45.25.0 → 45.25.2

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.
@@ -1,28 +1,14 @@
1
1
  import { shallow, mount } from 'enzyme';
2
2
  import { useIntl } from 'react-intl';
3
3
 
4
+ import { mockMatchMedia, mockResizeObserver } from '../test-utils';
5
+
4
6
  import PhoneNumberInput from '.';
5
7
 
6
8
  jest.mock('react-intl');
7
9
 
8
- Object.defineProperty(window, 'matchMedia', {
9
- writable: true,
10
- value: jest.fn().mockImplementation((query) => ({
11
- matches: false,
12
- media: query,
13
- onchange: null,
14
- addListener: jest.fn(), // Deprecated
15
- removeListener: jest.fn(), // Deprecated
16
- addEventListener: jest.fn(),
17
- removeEventListener: jest.fn(),
18
- dispatchEvent: jest.fn(),
19
- })),
20
- });
21
-
22
- class ResizeObserver {
23
- observe() {}
24
- unobserve() {}
25
- }
10
+ mockMatchMedia();
11
+ mockResizeObserver();
26
12
 
27
13
  const simulatePaste = (element, value) =>
28
14
  element.simulate('paste', { nativeEvent: { clipboardData: { getData: () => value } } });
@@ -112,8 +98,6 @@ describe('Given a telephone number component', () => {
112
98
  });
113
99
 
114
100
  describe('when pasting', () => {
115
- window.ResizeObserver = ResizeObserver;
116
-
117
101
  beforeEach(() => {
118
102
  component = mount(<PhoneNumberInput {...props} initialValue="+39123456789" />);
119
103
  select = () => component.find(PREFIX_SELECT_SELECTOR);
@@ -76,6 +76,9 @@ const getUniqueIdForOption = (parentId = '', option) => {
76
76
  return `option-${parentId}-${uniqueOptionId}`;
77
77
  };
78
78
 
79
+ /**
80
+ * @deprecated Use `SelectInput` instead (https://neptune.wise.design/blog/2023-11-28-adopting-our-new-selectinput)
81
+ */
79
82
  export default function Select({
80
83
  placeholder,
81
84
  id,
@@ -17,3 +17,14 @@ export function mockMatchMedia() {
17
17
  }),
18
18
  });
19
19
  }
20
+
21
+ export function mockResizeObserver() {
22
+ // mock ResizeObserver because it's not implemented in jsdoc lib
23
+ // https://github.com/jsdom/jsdom/issues/3368
24
+ // eslint-disable-next-line compat/compat
25
+ window.ResizeObserver = class ResizeObserver {
26
+ observe = jest.fn();
27
+ unobserve = jest.fn();
28
+ disconnect = jest.fn();
29
+ };
30
+ }