From 3fd6bd240c8452b9e62e45c3d837d4046b8f5c1b Mon Sep 17 00:00:00 2001 From: Hannah Mudge Date: Wed, 8 Nov 2023 16:26:16 -0700 Subject: [PATCH] Add unit tests --- .../list_group_item.test.tsx.snap | 26 ++++++++++++++ .../list_group/list_group_item.test.tsx | 34 ++++++++++++++++++- src/components/list_group/list_group_item.tsx | 1 + 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/src/components/list_group/__snapshots__/list_group_item.test.tsx.snap b/src/components/list_group/__snapshots__/list_group_item.test.tsx.snap index 9be40de8636..f9e532caf9a 100644 --- a/src/components/list_group/__snapshots__/list_group_item.test.tsx.snap +++ b/src/components/list_group/__snapshots__/list_group_item.test.tsx.snap @@ -70,6 +70,32 @@ exports[`EuiListGroupItem props color text is rendered 1`] = ` `; +exports[`EuiListGroupItem props external is rendered 1`] = ` +
  • + + + Label + + + External link + + +
  • +`; + exports[`EuiListGroupItem props extraAction is rendered 1`] = `
  • { shouldRenderCustomStyles(); @@ -205,6 +209,34 @@ describe('EuiListGroupItem', () => { }); }); + describe('external', () => { + test('is rendered', () => { + const { container } = render( + + ); + expect(container.firstChild).toMatchSnapshot(); + }); + + test('target `_blank` renders external icon', () => { + const { getByTestSubject } = render( + + ); + expect(getByTestSubject('externalLinkIcon')).toBeInTheDocument(); + }); + + test('external prop can overwrite default target `_blank` behavior', async () => { + const { queryByTestSubject } = render( + + ); + expect(queryByTestSubject('externalLinkIcon')).toBeFalsy(); + }); + }); + describe('onClick', () => { test('is rendered', () => { const { container } = render( diff --git a/src/components/list_group/list_group_item.tsx b/src/components/list_group/list_group_item.tsx index 221e7fad0fc..9394cb98460 100644 --- a/src/components/list_group/list_group_item.tsx +++ b/src/components/list_group/list_group_item.tsx @@ -296,6 +296,7 @@ export const EuiListGroupItem: FunctionComponent = ({ size="s" css={innerStyles.externalIcon} type="popout" + data-test-subj='externalLinkIcon' /> );