Skip to content

Commit

Permalink
Fix jest test
Browse files Browse the repository at this point in the history
  • Loading branch information
kertal committed Jan 8, 2020
1 parent 398fe90 commit 5b89895
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,26 @@ export interface DiscoverIndexPatternProps {
* Component allows you to select an index pattern in discovers side bar
*/
export function DiscoverIndexPattern({
indexPatternList = [],
selectedIndexPattern = { id: '', attributes: { title: '' } } as SavedObject,
indexPatternList,
selectedIndexPattern,
setIndexPattern,
}: DiscoverIndexPatternProps) {
const options: IndexPatternRef[] = indexPatternList.map(entity => ({
const options: IndexPatternRef[] = (indexPatternList || []).map(entity => ({
id: entity.id,
title: entity.attributes!.title,
}));
const { id: selectedId, attributes } = selectedIndexPattern || {};

const [selected, setSelected] = useState({
id: selectedIndexPattern.id,
title: selectedIndexPattern.attributes!.title,
id: selectedId || '',
title: attributes ? attributes.title : '',
});

if (!indexPatternList || indexPatternList.length === 0 || !selectedIndexPattern) {
// just in case, shouldn't happen
return null;
}

return (
<div className="indexPattern__container">
<I18nProvider>
Expand Down

0 comments on commit 5b89895

Please sign in to comment.