Skip to content

Commit

Permalink
organizes exports/imports, adjusts refs, minor fixes/adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitropoulos committed Feb 18, 2020
1 parent 32731ac commit e3cac5c
Show file tree
Hide file tree
Showing 8 changed files with 215 additions and 197 deletions.
40 changes: 17 additions & 23 deletions src/components/combo_box/combo_box.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { ReactNode } from 'react';
import { shallow, render, mount } from 'enzyme';
import sinon from 'sinon';
import {
Expand All @@ -11,7 +11,7 @@ import { comboBoxKeyCodes } from '../../services';
import { EuiComboBox } from './combo_box';

jest.mock('../portal', () => ({
EuiPortal: ({ children }) => children,
EuiPortal: ({ children }: { children: ReactNode }) => children,
}));

// Mock the htmlIdGenerator to generate predictable ids for snapshot tests
Expand Down Expand Up @@ -71,7 +71,7 @@ describe('EuiComboBox', () => {
describe('props', () => {
test('options list is rendered', () => {
const component = mount(
<EuiComboBox<TitanOption>
<EuiComboBox
options={options}
data-test-subj="alsoGetsAppliedToOptionsList"
/>
Expand All @@ -83,7 +83,7 @@ describe('props', () => {

test('selectedOptions are rendered', () => {
const component = shallow(
<EuiComboBox<TitanOption>
<EuiComboBox
options={options}
selectedOptions={[options[2], options[4]]}
/>
Expand All @@ -95,15 +95,15 @@ describe('props', () => {
describe('isClearable=false disallows user from clearing input', () => {
test('when no options are selected', () => {
const component = shallow(
<EuiComboBox<TitanOption> options={options} isClearable={false} />
<EuiComboBox options={options} isClearable={false} />
);

expect(component).toMatchSnapshot();
});

test('when options are selected', () => {
const component = shallow(
<EuiComboBox<TitanOption>
<EuiComboBox
options={options}
selectedOptions={[options[2], options[4]]}
isClearable={false}
Expand All @@ -117,7 +117,7 @@ describe('props', () => {
describe('singleSelection', () => {
test('is rendered', () => {
const component = shallow(
<EuiComboBox<TitanOption>
<EuiComboBox
options={options}
selectedOptions={[options[2]]}
singleSelection={true}
Expand All @@ -128,7 +128,7 @@ describe('props', () => {
});
test('selects existing option when opened', () => {
const component = shallow(
<EuiComboBox<TitanOption>
<EuiComboBox
options={options}
selectedOptions={[options[2]]}
singleSelection={true}
Expand All @@ -142,7 +142,7 @@ describe('props', () => {

test('isDisabled is rendered', () => {
const component = shallow(
<EuiComboBox<TitanOption>
<EuiComboBox
options={options}
selectedOptions={[options[2]]}
isDisabled={true}
Expand All @@ -154,7 +154,7 @@ describe('props', () => {

test('full width is rendered', () => {
const component = shallow(
<EuiComboBox<TitanOption>
<EuiComboBox
options={options}
selectedOptions={[options[2]]}
fullWidth={true}
Expand All @@ -171,7 +171,7 @@ describe('behavior', () => {
const onCreateOptionHandler = sinon.spy();

const component = mount(
<EuiComboBox<TitanOption>
<EuiComboBox
options={options}
selectedOptions={[options[2]]}
onCreateOption={onCreateOptionHandler}
Expand All @@ -190,7 +190,7 @@ describe('behavior', () => {
const onCreateOptionHandler = sinon.spy();

const component = mount(
<EuiComboBox<TitanOption>
<EuiComboBox
options={options}
selectedOptions={[options[2]]}
onCreateOption={onCreateOptionHandler}
Expand All @@ -209,10 +209,7 @@ describe('behavior', () => {
const onKeyDownWrapper = jest.fn();
const component = mount(
<div onKeyDown={onKeyDownWrapper}>
<EuiComboBox<TitanOption>
options={options}
selectedOptions={[options[2]]}
/>
<EuiComboBox options={options} selectedOptions={[options[2]]} />
</div>
);

Expand All @@ -236,7 +233,7 @@ describe('behavior', () => {
const onCreateOptionHandler = sinon.spy();

const component = mount(
<EuiComboBox<TitanOption>
<EuiComboBox
options={options}
selectedOptions={[options[2]]}
onCreateOption={onCreateOptionHandler}
Expand All @@ -261,10 +258,7 @@ describe('behavior', () => {
const onKeyDownWrapper = jest.fn();
const component = mount(
<div onKeyDown={onKeyDownWrapper}>
<EuiComboBox<TitanOption>
options={options}
selectedOptions={[options[2]]}
/>
<EuiComboBox options={options} selectedOptions={[options[2]]} />
</div>
);

Expand Down Expand Up @@ -292,7 +286,7 @@ describe('behavior', () => {
test('calls onChange callback with empty array', () => {
const onChangeHandler = sinon.spy();
const component = mount(
<EuiComboBox<TitanOption>
<EuiComboBox
options={options}
selectedOptions={[options[2]]}
onChange={onChangeHandler}
Expand All @@ -306,7 +300,7 @@ describe('behavior', () => {

test('focuses the input', () => {
const component = mount(
<EuiComboBox<TitanOption>
<EuiComboBox
options={options}
selectedOptions={[options[2]]}
onChange={() => {}}
Expand Down
Loading

0 comments on commit e3cac5c

Please sign in to comment.