From 96e642eb2ca6ccc7e0f75ed2bcf2b04ec20266a0 Mon Sep 17 00:00:00 2001 From: oatkiller Date: Mon, 13 Jul 2020 18:50:13 -0400 Subject: [PATCH] test uses data-test-subj instead of component reference --- .../components/timeline/body/index.test.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/index.test.tsx index 5377002dbf492..1e5eff8b79796 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/index.test.tsx @@ -18,6 +18,7 @@ import { Sort } from './sort'; import { wait } from '../../../../common/lib/helpers'; import { useMountAppended } from '../../../../common/utils/use_mount_appended'; import { SELECTOR_TIMELINE_BODY_CLASS_NAME, TimelineBody } from '../styles'; +import { ReactWrapper } from '@elastic/eui/node_modules/@types/enzyme'; const testBodyHeight = 700; const mockGetNotesByIds = (eventId: string[]) => []; @@ -162,8 +163,17 @@ describe('Body', () => { ); + + // The value returned if `wrapper.find` returns a `TimelineBody` instance. + type TimelineBodyEnzymeWrapper = ReactWrapper>; + + // The first TimelineBody component + const timelineBody: TimelineBodyEnzymeWrapper = wrapper + .find('[data-test-subj="timeline-body"]') + .first() as TimelineBodyEnzymeWrapper; + // the timeline body still renders, but it gets a `display: none` style via `styled-components`. - expect(wrapper.find(TimelineBody).props().visible).toBe(false); + expect(timelineBody.props().visible).toBe(false); }); }); });