// eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-nocheck import React from 'react' // TODO: React test renderer is depracated, we should use @testing-library/react // https://react.dev/warnings/react-test-renderer import renderer from 'react-test-renderer' import prettier from 'prettier' import { TextEncoder } from 'util' if (typeof global.TextEncoder === 'undefined') { global.TextEncoder = TextEncoder } import ClipServer from '../template/index' const formatString = (html) => prettier.format(html, { parser: 'html', printWidth: 80, // Specify your preferred line width tabWidth: 2, // Specify your preferred tab width useTabs: false, // Use spaces instead of tabs // Additional prettier options... }) describe('Clip Snapshot', () => { describe('component rendered on server', () => { const id = 'https://api.ft.com/content/00000000-0000-0000-0000-000000000000' const url = 'localhost:8080/fakevideo.mpg' const poster = 'localhost:8080/fakeposter.jpg' const clips = [ { dataSource: [ { binaryUrl: url, mediaType: 'video/mp4', }, ], }, ] const clipsWithPoster = [ { dataSource: [ { binaryUrl: url, mediaType: 'video/mp4', }, ], poster, }, ] describe('ContentLayout integration tests', () => { it('inset-left render - should wrap in ContentLayout with proper classes', () => { const tree = renderer .create( ) .toJSON() expect(formatString(tree)).toMatchSnapshot() }) it('inset-right render - should wrap in ContentLayout with proper classes', () => { const tree = renderer .create( ) .toJSON() expect(formatString(tree)).toMatchSnapshot() }) it('edge case: custom dataLayout value should wrap in ContentLayout', () => { const tree = renderer .create( ) .toJSON() expect(formatString(tree)).toMatchSnapshot() }) it('returns an empty string when clips is empty', () => { const tree = renderer .create( ) .toJSON() expect(tree).toMatchSnapshot() }) }) it('in-line render', () => { const tree = renderer .create( ) .toJSON() expect(formatString(tree)).toMatchSnapshot() }) it('full-grid default render', () => { const tree = renderer .create( ) .toJSON() expect(formatString(tree)).toMatchSnapshot() }) it('mid-grid default render', () => { const tree = renderer .create( ) .toJSON() expect(formatString(tree)).toMatchSnapshot() }) it('in-line render with attributes', () => { const tree = renderer .create( ) .toJSON() expect(formatString(tree)).toMatchSnapshot() }) it('full-grid render with attributes', () => { const tree = renderer .create( ) .toJSON() expect(formatString(tree)).toMatchSnapshot() }) it('mid-grid render with attributes', () => { const tree = renderer .create( ) .toJSON() expect(formatString(tree)).toMatchSnapshot() }) it('renders multiple video sources', () => { const videoWithMultipleSources = { content: { layoutWidth: 'in-line', id: 'https://api.ft.com/content/84d7e1b0-e8b2-4ffc-a798-306f29dc9d52', description: ' Dolor sit amet, consectetur adipiscing elit. Sed sit amet odio quis ante auctor dapibus. Sed dapibus cursus nisi, tincidunt sagittis sapien vehicula vitae.', caption: 'Aenean lobortis volutpat nunc vitae elementum', clips: [ { dataSource: [ { binaryUrl: 'https://whatever/1080x1920.mp4', mediaType: 'video/mp4', pixelHeight: 1080, pixelWidth: 1920, }, { binaryUrl: 'https://whatever/320x240.mp4', mediaType: 'video/mp4', pixelHeight: 320, pixelWidth: 240, }, { binaryUrl: 'https://whatever/640x480.avi', mediaType: 'video/avi', pixelHeight: 640, pixelWidth: 480, }, ], poster: 'https://whatever/1080x1920.jpg', }, ], }, } const tree = renderer .create() .toJSON() expect(formatString(tree)).toMatchSnapshot() }) // Temporary test to check that the new Origami image is supported. it('supports new Origami images, fallbacking to the previous implementation', () => { const tree = renderer .create( ) .toJSON() expect(formatString(tree)).toMatchSnapshot() }) }) })