🎥 Make videos programmatically with React
fix test
Jonny Burgerdfb5511d4d92
diff --git a/packages/core/src/Sequence.tsx b/packages/core/src/Sequence.tsxindex e96c3e282a..537620435d 100644--- a/packages/core/src/Sequence.tsx+++ b/packages/core/src/Sequence.tsx@@ -85,13 +85,6 @@ const SequenceRefForwardingFunction: React.ForwardRefRenderFunction<);}- // Infinity is non-integer but allowed!- if (durationInFrames % 1 !== 0 && Number.isFinite(durationInFrames)) {- throw new TypeError(- `The "durationInFrames" of a sequence must be an integer, but got ${durationInFrames}.`- );- }-if (typeof from !== 'number') {throw new TypeError(`You passed to the "from" props of your <Sequence> an argument of type ${typeof from}, but it must be a number.`diff --git a/packages/core/src/test/loop-validation.test.tsx b/packages/core/src/test/loop-validation.test.tsxindex 1b4b2dc83b..1ca0aec1a3 100644--- a/packages/core/src/test/loop-validation.test.tsx+++ b/packages/core/src/test/loop-validation.test.tsx@@ -4,12 +4,14 @@import {render} from '@testing-library/react';import type {ComponentType} from 'react';import React, {useContext} from 'react';+import {renderToString} from 'react-dom/server';import {describe, expect, test} from 'vitest';import {CanUseRemotionHooksProvider} from '../CanUseRemotionHooks.js';import {CompositionManager} from '../CompositionManager.js';import {Loop} from '../loop/index.js';import {RemotionRoot} from '../RemotionRoot.js';import {expectToThrow} from './expect-to-throw.js';+import {WrapSequenceContext} from './wrap-sequence-context.js';const Wrapper: React.FC<{children: React.ReactNode;@@ -65,14 +67,16 @@ describe('Loop-validation render should throw with invalid props', () => {);});test('It should throw if Loop has non-integer durationInFrames', () => {- expectToThrow(- () =>- render(+ expect(+ renderToString(+ <WrapSequenceContext><Wrapper><Loop durationInFrames={1.1}>hi</Loop></Wrapper>- ),- /The "durationInFrames" prop of the <Loop \/> component must be an integer, but got 1.1./+ </WrapSequenceContext>+ )+ ).toBe(+ '<div style="position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;display:flex">hi</div>');});test('It should throw if Loop has a negative duration', () => {diff --git a/packages/core/src/test/sequence-validation.test.tsx b/packages/core/src/test/sequence-validation.test.tsxindex 83574c80e4..78cb3470d2 100644--- a/packages/core/src/test/sequence-validation.test.tsx+++ b/packages/core/src/test/sequence-validation.test.tsx@@ -2,6 +2,7 @@* @vitest-environment jsdom*/import {render} from '@testing-library/react';+import {renderToString} from 'react-dom/server';import {describe, expect, test} from 'vitest';import {CanUseRemotionHooksProvider} from '../CanUseRemotionHooks.js';import {Sequence} from '../Sequence.js';@@ -11,14 +12,18 @@ import {WrapSequenceContext} from './wrap-sequence-context.js';describe('Composition-validation render should throw with invalid props', () => {describe('Throw with invalid duration props', () => {test('It should throw if Sequence has non-integer durationInFrames', () => {- expectToThrow(- () =>- render(- <Sequence from={0} durationInFrames={1.1}>- hi- </Sequence>- ),- /The "durationInFrames" of a sequence must be an integer, but got 1.1./+ expect(+ renderToString(+ <CanUseRemotionHooksProvider>+ <WrapSequenceContext>+ <Sequence from={0} durationInFrames={1.1}>+ hi+ </Sequence>+ </WrapSequenceContext>+ </CanUseRemotionHooksProvider>+ )+ ).toBe(+ '<div style="position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;display:flex">hi</div>');});test('It should throw if Sequence has negative duration', () => {@@ -38,17 +43,6 @@ describe('Composition-validation render should throw with invalid props', () =>/You passed to the "from" props of your <Sequence> an argument of type string, but it must be a number./);});- test('It should throw if Sequence has non-integer from', () => {- expectToThrow(- () =>- render(- <Sequence from={0.1} durationInFrames={1}>- hi- </Sequence>- ),- /The "from" prop of a sequence must be an integer, but got 0.1./- );- });});test('It should throw for invalid layout value', () => {expectToThrow(diff --git a/packages/core/src/test/series.test.tsx b/packages/core/src/test/series.test.tsxindex 520e03c3b1..6c1a541d3e 100644--- a/packages/core/src/test/series.test.tsx+++ b/packages/core/src/test/series.test.tsx@@ -159,7 +159,7 @@ test('Should throw if invalid or no duration provided', () => {</Series>);}).toThrow(- /The "durationInFrames" prop of a <Series.Sequence \/> component must be an integer, but got NaN./+ /The "durationInFrames" prop of a <Series.Sequence \/> component must be finite, but got NaN./);expect(() => {renderForFrame(@@ -371,6 +371,6 @@ test('Disallow durationInFrames as Infinity for first n-1 Series.Sequence', () =</WrapSequenceContext>);}).toThrow(- /The "durationInFrames" prop of a <Series.Sequence \/> component must be an integer, but got Infinity\./+ /The "durationInFrames" prop of a <Series.Sequence \/> component must be finite, but got Infinity\./);});