import React from 'react' import { render } from '@testing-library/react' import Flourish from '../' enum acceptedFormat { standard = 'standard', } const anImage = { id: '123', url: 'https://example.com/image.jpg', width: 100, height: 150, format: 'standard' as acceptedFormat, sourceSet: [ { url: 'https://example.com/anotherImage.jpg', width: 200, dpr: 2, }, ], } describe('Flourish component', () => { it('renders with a full-grid layout and fallback image', async () => { const { container } = render( ) expect(container).toMatchSnapshot() }) it('renders ignoring layout different from full-grid', async () => { const { container } = render( ) expect(container).toMatchSnapshot() }) it('renders with an iframe rather than using the embed script to insert it', async () => { const iFrame = true const { container } = render( ) expect(container).toMatchSnapshot() }) it('renders without n-content-layout class for charts not in article body', async () => { const inArticleBody = false const { container } = render( ) expect(container).toMatchSnapshot() }) it('renders with fragmentIdentifier as ID', () => { const { container } = render( ) const flourishElement = container.querySelector('[id="test"]') expect(flourishElement).toBeTruthy() }) }) it('sets the hideTitle param in the iframe url to true when not in article body', async () => { const inArticleBody = false const iFrame = true const { container } = render( ) expect(container).toMatchSnapshot() }) it('does not set aspect ratios when in article body', async () => { const { container } = render( ) expect(container).toMatchSnapshot() })