Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
-use const as type

- revert newline changes
  • Loading branch information
mgadewoll committed May 3, 2024
1 parent c50b604 commit 9929c3e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/components/combo_box/combo_box.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ import React, { useCallback, useState } from 'react';
import type { Meta, StoryObj } from '@storybook/react';
import { action } from '@storybook/addon-actions';

import { ToolTipPositions } from '../tool_tip';
import { EuiComboBox, EuiComboBoxProps } from './combo_box';
import { EuiComboBoxOptionMatcher } from './types';
import { EuiCode } from '../code';

const toolTipProps = {
toolTipContent: 'This is a tooltip!',
toolTipProps: { position: 'left' as ToolTipPositions },
toolTipProps: { position: 'left' as const },
value: 4,
};

Expand Down
11 changes: 11 additions & 0 deletions src/components/combo_box/combo_box.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -525,21 +525,26 @@ describe('EuiComboBox', () => {
describe('tabbing off the search input', () => {
it("closes the options list if the user isn't navigating the options", async () => {
const keyDownBubbled = jest.fn();

const { getByTestSubject } = render(
<div onKeyDown={keyDownBubbled}>
<EuiComboBox options={options} selectedOptions={[options[2]]} />
</div>
);
await showEuiComboBoxOptions();

const mockEvent = { key: keys.TAB, shiftKey: true };
fireEvent.keyDown(getByTestSubject('comboBoxSearchInput'), mockEvent);

// If the TAB keydown bubbled up to the wrapper, then a browser DOM would shift the focus
expect(keyDownBubbled).toHaveBeenCalledWith(
expect.objectContaining(mockEvent)
);
});

it('calls onCreateOption', () => {
const onCreateOptionHandler = jest.fn();

const { getByTestSubject } = render(
<EuiComboBox
options={options}
Expand All @@ -548,23 +553,29 @@ describe('EuiComboBox', () => {
/>
);
const input = getByTestSubject('comboBoxSearchInput');

fireEvent.change(input, { target: { value: 'foo' } });
fireEvent.blur(input);

expect(onCreateOptionHandler).toHaveBeenCalledTimes(1);
expect(onCreateOptionHandler).toHaveBeenCalledWith('foo', options);
});

it('does nothing if the user is navigating the options', async () => {
const keyDownBubbled = jest.fn();

const { getByTestSubject } = render(
<div onKeyDown={keyDownBubbled}>
<EuiComboBox options={options} selectedOptions={[options[2]]} />
</div>
);
await showEuiComboBoxOptions();

// Navigate to an option then tab off
const input = getByTestSubject('comboBoxSearchInput');
fireEvent.keyDown(input, { key: keys.ARROW_DOWN });
fireEvent.keyDown(input, { key: keys.TAB });

// If the TAB keydown did not bubble to the wrapper, then the tab event was prevented
expect(keyDownBubbled).not.toHaveBeenCalled();
});
Expand Down

0 comments on commit 9929c3e

Please sign in to comment.