Skip to content

Commit

Permalink
test uses data-test-subj instead of component reference
Browse files Browse the repository at this point in the history
  • Loading branch information
oatkiller committed Jul 13, 2020
1 parent b0b048b commit 96e642e
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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[]) => [];
Expand Down Expand Up @@ -162,8 +163,17 @@ describe('Body', () => {
<Body {...props} />
</TestProviders>
);

// The value returned if `wrapper.find` returns a `TimelineBody` instance.
type TimelineBodyEnzymeWrapper = ReactWrapper<React.ComponentProps<typeof TimelineBody>>;

// 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);
});
});
});
Expand Down

0 comments on commit 96e642e

Please sign in to comment.