From 667ed3ea826d3c946c8eb0be85ff968b213d450e Mon Sep 17 00:00:00 2001 From: Alex Demchenko Date: Mon, 30 Aug 2021 21:07:35 +0200 Subject: [PATCH] Fix tests --- src/LinkPreview.tsx | 10 +++++++--- src/__tests__/LinkPreview.test.tsx | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/LinkPreview.tsx b/src/LinkPreview.tsx index 8974b95..6dadbb5 100644 --- a/src/LinkPreview.tsx +++ b/src/LinkPreview.tsx @@ -122,6 +122,10 @@ export const LinkPreview = React.memo( } const renderImageNode = (image: PreviewDataImage) => { + // aspectRatio shouldn't be undefined, just an additional check + /* istanbul ignore next */ + const ar = aspectRatio ?? 1 + return oneOf( renderImage, { expect(headerNode).toBeDefined() }) + it('renders vertical image node', async () => { + expect.assertions(1) + const link = 'https://dummyimage.com/300x800/000/fff' + const { getByRole, getByText } = render( + + ) + await waitFor(() => getByText(link)) + const image = getByRole('image') + expect(image.props).toHaveProperty('style.height', 0) + }) + it('responses to the layout event change', async () => { expect.assertions(1) const link = 'https://github.com/flyerhq/'