Skip to content

Commit c66ce60

Browse files
authored
Merge pull request JedWatson#4480 from JedWatson/unskip-autofocus-unit-tests
Fix skipped unit tests for autoFocus and onChange
2 parents f3c0bb5 + 18e1866 commit c66ce60

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

packages/react-select/src/__tests__/Select.test.js

+11-18
Original file line numberDiff line numberDiff line change
@@ -2040,10 +2040,6 @@ cases(
20402040
}
20412041
);
20422042

2043-
/**
2044-
* onFocus hook is not being called when component is mounted is autoFocus true
2045-
* Reproducible here -> https://codesandbox.io/s/71xrkj0qj
2046-
*/
20472043
cases(
20482044
'onFocus prop with autoFocus',
20492045
({ props = { ...BASIC_PROPS, autoFocus: true } }) => {
@@ -2056,10 +2052,12 @@ cases(
20562052
},
20572053
{
20582054
'single select > should call auto focus only once when select is autoFocus': {
2059-
skip: true,
2055+
props: {
2056+
...BASIC_PROPS,
2057+
autoFocus: true,
2058+
},
20602059
},
20612060
'multi select > should call auto focus only once when select is autoFocus': {
2062-
skip: true,
20632061
props: {
20642062
...BASIC_PROPS,
20652063
autoFocus: true,
@@ -2732,18 +2730,13 @@ test('to clear value when hitting escape if escapeClearsValue and isClearable ar
27322730
});
27332731
});
27342732

2735-
/**
2736-
* Selects the option on hitting spacebar on V2
2737-
* Needs varification
2738-
*/
2739-
test.skip('hitting spacebar should not select option if isSearchable is true (default)', () => {
2740-
// let onChangeSpy = jest.fn();
2741-
// let props = { ...BASIC_PROPS, onChange: onChangeSpy };
2742-
// let { container } = render(<Select {...props} menuIsOpen />);
2743-
// // Open Menu
2744-
// selectWrapper.setState({ focusedOption: OPTIONS[0] });
2745-
// fireEvent.keyDown(container, { keyCode: 32, key: ' ' });
2746-
// expect(onChangeSpy).not.toHaveBeenCalled();
2733+
test('hitting spacebar should not select option if isSearchable is true (default)', () => {
2734+
let onChangeSpy = jest.fn();
2735+
let props = { ...BASIC_PROPS, onChange: onChangeSpy };
2736+
let { container } = render(<Select {...props} menuIsOpen />);
2737+
// Open Menu
2738+
fireEvent.keyDown(container, { keyCode: 32, key: ' ' });
2739+
expect(onChangeSpy).not.toHaveBeenCalled();
27472740
});
27482741

27492742
test('renders with custom theme', () => {

0 commit comments

Comments
 (0)