@transferwise/components 0.0.0-experimental-dd4474f → 0.0.0-experimental-e95c8a5

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": "@transferwise/components",
3
- "version": "0.0.0-experimental-dd4474f",
3
+ "version": "0.0.0-experimental-e95c8a5",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -78,8 +78,8 @@
78
78
  "rollup": "^3.28.1",
79
79
  "storybook": "^7.4.5",
80
80
  "@transferwise/less-config": "3.0.6",
81
- "@transferwise/neptune-css": "14.5.2",
82
- "@wise/components-theming": "0.8.4"
81
+ "@wise/components-theming": "0.8.4",
82
+ "@transferwise/neptune-css": "14.5.2"
83
83
  },
84
84
  "peerDependencies": {
85
85
  "@transferwise/icons": "^3.7.0",
@@ -1,5 +1,5 @@
1
1
  import { act, screen, within } from '@testing-library/react';
2
- import userEvent from '@testing-library/user-event';
2
+ import userEvent, { specialChars } from '@testing-library/user-event';
3
3
 
4
4
  import { render } from '../test-utils';
5
5
 
@@ -66,12 +66,55 @@ describe('SelectInput', () => {
66
66
  });
67
67
 
68
68
  const listbox = screen.getByRole('listbox');
69
- expect(listbox).toBeInTheDocument();
70
-
71
69
  const option = within(listbox).getByRole('option', { name: 'EUR' });
72
- expect(option).toBeInTheDocument();
70
+ userEvent.click(option);
71
+
72
+ expect(trigger).toHaveTextContent('EUR');
73
+ });
74
+
75
+ it('filters items via keyboard', async () => {
76
+ render(
77
+ <SelectInput
78
+ items={[
79
+ {
80
+ type: 'group',
81
+ label: 'Popular currencies',
82
+ options: [
83
+ { type: 'option', value: 'USD' },
84
+ { type: 'option', value: 'EUR' },
85
+ { type: 'option', value: 'GBP' },
86
+ ],
87
+ },
88
+ ]}
89
+ filterable
90
+ />,
91
+ );
73
92
 
93
+ const trigger = screen.getAllByRole('button')[0];
94
+ // eslint-disable-next-line @typescript-eslint/require-await
95
+ await act(async () => {
96
+ userEvent.tab();
97
+ userEvent.keyboard(specialChars.enter);
98
+ });
99
+
100
+ const listbox = screen.getByRole('listbox');
101
+ expect(within(listbox).getAllByRole('option')).toHaveLength(3);
102
+
103
+ userEvent.keyboard('u');
104
+ expect(within(listbox).getAllByRole('option')).toHaveLength(2);
105
+
106
+ userEvent.keyboard('r');
107
+ expect(within(listbox).getByRole('option')).toBeInTheDocument();
108
+
109
+ userEvent.keyboard('x');
110
+ expect(within(listbox).queryByRole('option')).not.toBeInTheDocument();
111
+
112
+ userEvent.keyboard(specialChars.backspace);
113
+ expect(within(listbox).getByRole('option')).toBeInTheDocument();
114
+
115
+ const option = within(listbox).getAllByRole('option')[0];
74
116
  userEvent.click(option);
117
+
75
118
  expect(trigger).toHaveTextContent('EUR');
76
119
  });
77
120
  });