Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove options defaultProps value from EuiSuperSelect #1975

Merged
merged 4 commits into from
May 29, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/components/form/super_select/super_select.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,5 +318,4 @@ EuiSuperSelect.defaultProps = {
fullWidth: false,
compressed: false,
isInvalid: false,
options: [],
};
28 changes: 18 additions & 10 deletions src/components/form/super_select/super_select.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,19 @@ jest.mock('../../portal', () => ({
EuiPortal: ({ children }) => children,
}));

const options = [
{ value: '1', inputDisplay: 'Option #1' },
{ value: '2', inputDisplay: 'Option #2' },
];

describe('EuiSuperSelect', () => {
test('is rendered', () => {
const component = render(
<EuiSuperSelect {...requiredProps} onChange={() => {}} />
<EuiSuperSelect
{...requiredProps}
options={options}
onChange={() => {}}
/>
);

expect(component).toMatchSnapshot();
Expand All @@ -22,7 +31,12 @@ describe('EuiSuperSelect', () => {
describe('props', () => {
test('fullWidth is rendered', () => {
const component = render(
<EuiSuperSelect {...requiredProps} onChange={() => {}} fullWidth />
<EuiSuperSelect
{...requiredProps}
options={options}
onChange={() => {}}
fullWidth
/>
);

expect(component).toMatchSnapshot();
Expand All @@ -45,10 +59,7 @@ describe('EuiSuperSelect', () => {
test('options are rendered when select is open', () => {
const component = mount(
<EuiSuperSelect
options={[
{ value: '1', inputDisplay: 'Option #1' },
{ value: '2', inputDisplay: 'Option #2' },
]}
options={options}
onChange={() => {}}
data-test-subj="superSelect"
/>
Expand All @@ -62,10 +73,7 @@ describe('EuiSuperSelect', () => {
test('valueSelected is rendered', () => {
const component = render(
<EuiSuperSelect
options={[
{ value: '1', inputDisplay: 'Option #1' },
{ value: '2', inputDisplay: 'Option #2' },
]}
options={options}
valueOfSelected="2"
onChange={() => {}}
/>
Expand Down
4 changes: 3 additions & 1 deletion src/components/form/super_select/super_select_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export const EuiSuperSelectControl = ({
let selectedValue = '';
if (value) {
const selectedOption = options.find(option => option.value === value);
selectedValue = selectedOption.inputDisplay;
selectedValue = selectedOption
? selectedOption.inputDisplay
: selectedValue;
}

const icon = {
Expand Down