Skip to content

🎥 Make videos programmatically with React

better sequence testing

Jonas Brunnerc5ba78565aa8
diff --git a/packages/core/src/sequencing/index.tsx b/packages/core/src/sequencing/index.tsx
index 323ca59dd4..c19d969407 100644
--- a/packages/core/src/sequencing/index.tsx
+++ b/packages/core/src/sequencing/index.tsx
@@ -35,7 +35,7 @@ export const Sequence: React.FC<{
if (layout !== 'absolute-fill' && layout !== 'none') {
throw new TypeError(
- `The layout prop of <Composition /> expects either "absolute-fill" or "none", but you passed: ${layout}`
+ `The layout prop of <Sequence /> expects either "absolute-fill" or "none", but you passed: ${layout}`
);
}
diff --git a/packages/core/src/test/sequence-validation.test.tsx b/packages/core/src/test/sequence-validation.test.tsx
index 961dcad0ab..3e18c6729a 100644
--- a/packages/core/src/test/sequence-validation.test.tsx
+++ b/packages/core/src/test/sequence-validation.test.tsx
@@ -3,6 +3,14 @@ import React from 'react';
import {Sequence} from '../sequencing';
import {expectToThrow} from './expect-to-throw';
+test('It should throw if "from" props is not a number', () => {
+ expectToThrow(
+ // @ts-expect-error
+ () => render(<Sequence from={'0'} durationInFrames={30} />),
+ /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 missing duration', () => {
expectToThrow(
// @ts-expect-error
@@ -11,6 +19,14 @@ test('It should throw if Sequence has missing duration', () => {
);
});
+test('It should throw if Sequence has negative duration', () => {
+ expectToThrow(
+ // @ts-expect-error
+ () => render(<Sequence from={0} durationInFrames={-1} />),
+ /durationInFrames must be positive, but got -1/
+ );
+});
+
test('It should allow null as children', () => {
expect(() =>
render(
@@ -30,3 +46,14 @@ test('It should allow undefined as children', () => {
)
).not.toThrow();
});
+
+test('It should throw for invalid layout value', () => {
+ expectToThrow(
+ () =>
+ render(
+ // @ts-expect-error
+ <Sequence from={0} durationInFrames={100} layout={'invalid-value'} />
+ ),
+ /The layout prop of <Sequence \/> expects either "absolute-fill" or "none", but you passed: invalid-value/
+ );
+});