Skip to content

Commit

Permalink
Merge pull request #4480 from JedWatson/unskip-autofocus-unit-tests
Browse files Browse the repository at this point in the history
Fix skipped unit tests for autoFocus and onChange
  • Loading branch information
JedWatson authored Mar 19, 2021
2 parents f3c0bb5 + 18e1866 commit c66ce60
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions packages/react-select/src/__tests__/Select.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2040,10 +2040,6 @@ cases(
}
);

/**
* onFocus hook is not being called when component is mounted is autoFocus true
* Reproducible here -> https://codesandbox.io/s/71xrkj0qj
*/
cases(
'onFocus prop with autoFocus',
({ props = { ...BASIC_PROPS, autoFocus: true } }) => {
Expand All @@ -2056,10 +2052,12 @@ cases(
},
{
'single select > should call auto focus only once when select is autoFocus': {
skip: true,
props: {
...BASIC_PROPS,
autoFocus: true,
},
},
'multi select > should call auto focus only once when select is autoFocus': {
skip: true,
props: {
...BASIC_PROPS,
autoFocus: true,
Expand Down Expand Up @@ -2732,18 +2730,13 @@ test('to clear value when hitting escape if escapeClearsValue and isClearable ar
});
});

/**
* Selects the option on hitting spacebar on V2
* Needs varification
*/
test.skip('hitting spacebar should not select option if isSearchable is true (default)', () => {
// let onChangeSpy = jest.fn();
// let props = { ...BASIC_PROPS, onChange: onChangeSpy };
// let { container } = render(<Select {...props} menuIsOpen />);
// // Open Menu
// selectWrapper.setState({ focusedOption: OPTIONS[0] });
// fireEvent.keyDown(container, { keyCode: 32, key: ' ' });
// expect(onChangeSpy).not.toHaveBeenCalled();
test('hitting spacebar should not select option if isSearchable is true (default)', () => {
let onChangeSpy = jest.fn();
let props = { ...BASIC_PROPS, onChange: onChangeSpy };
let { container } = render(<Select {...props} menuIsOpen />);
// Open Menu
fireEvent.keyDown(container, { keyCode: 32, key: ' ' });
expect(onChangeSpy).not.toHaveBeenCalled();
});

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

0 comments on commit c66ce60

Please sign in to comment.