From 695dc424d9182bb1343129a14059feac76ac16c4 Mon Sep 17 00:00:00 2001 From: Tomasz Kajtoch Date: Mon, 24 Jul 2023 17:17:01 +0200 Subject: [PATCH] fix EuiComboBox tests --- .../__snapshots__/combo_box.test.tsx.snap | 6 ++++++ src/components/combo_box/combo_box.test.tsx | 13 +++++++------ .../combo_box_input/combo_box_pill.tsx | 18 +++++++++++++++--- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/components/combo_box/__snapshots__/combo_box.test.tsx.snap b/src/components/combo_box/__snapshots__/combo_box.test.tsx.snap index afbbd06df786..e16aed9df81f 100644 --- a/src/components/combo_box/__snapshots__/combo_box.test.tsx.snap +++ b/src/components/combo_box/__snapshots__/combo_box.test.tsx.snap @@ -417,6 +417,7 @@ exports[`props option.prepend & option.append renders in pills 1`] = ` Array [ Pre @@ -448,6 +450,7 @@ Array [ , Post @@ -483,9 +487,11 @@ Array [ exports[`props option.prepend & option.append renders in single selection 1`] = ` Pre diff --git a/src/components/combo_box/combo_box.test.tsx b/src/components/combo_box/combo_box.test.tsx index 80fa27d76842..ce808e1000fa 100644 --- a/src/components/combo_box/combo_box.test.tsx +++ b/src/components/combo_box/combo_box.test.tsx @@ -124,13 +124,13 @@ describe('props', () => { ]; test('renders in pills', () => { - const component = render( + const { getByTestSubject, getAllByTestSubject } = render( ); - expect(component.find('.euiComboBoxPill__prepend')).toHaveLength(1); - expect(component.find('.euiComboBoxPill__append')).toHaveLength(1); - expect(component.find('.euiComboBoxPill')).toMatchSnapshot(); + expect(getByTestSubject('euiComboBoxPillPrepend')).toBeInTheDocument(); + expect(getByTestSubject('euiComboBoxPillAppend')).toBeInTheDocument(); + expect(getAllByTestSubject('euiComboBoxPill')).toMatchSnapshot(); }); test('renders in the options dropdown', () => { @@ -146,14 +146,15 @@ describe('props', () => { }); test('renders in single selection', () => { - const component = render( + const { getByTestSubject } = render( ); - expect(component.find('.euiComboBoxPill')).toMatchSnapshot(); + + expect(getByTestSubject('euiComboBoxPill')).toMatchSnapshot(); }); }); diff --git a/src/components/combo_box/combo_box_input/combo_box_pill.tsx b/src/components/combo_box/combo_box_input/combo_box_pill.tsx index 389f4bc8d16c..e200a5a2cc0c 100644 --- a/src/components/combo_box/combo_box_input/combo_box_pill.tsx +++ b/src/components/combo_box/combo_box_input/combo_box_pill.tsx @@ -69,11 +69,21 @@ export class EuiComboBoxPill extends Component> { const content = ( <> {option.prepend && ( - {option.prepend} + + {option.prepend} + )} {children} {option.append && ( - {option.append} + + {option.append} + )} ); @@ -89,6 +99,7 @@ export class EuiComboBoxPill extends Component> { extends Component> { if (asPlainText) { return ( - + {content} ); @@ -116,6 +127,7 @@ export class EuiComboBoxPill extends Component> {