Skip to content

🎥 Make videos programmatically with React

improve test code quality & remove duplicated code

Tobias Boner721bc04203c2
diff --git a/packages/core/src/test/absolute-src.test.ts b/packages/core/src/test/absolute-src.test.ts
index 617f7aa774..916a47ef62 100644
--- a/packages/core/src/test/absolute-src.test.ts
+++ b/packages/core/src/test/absolute-src.test.ts
@@ -1,11 +1,17 @@
import {getAbsoluteSrc} from '../absolute-src';
-test('Absolute src should behave as expected', () => {
- expect(getAbsoluteSrc('http://localhost:8080')).toBe(
- 'http://localhost:8080/'
- );
- expect(getAbsoluteSrc('/hi')).toBe('http://localhost/hi');
- expect(getAbsoluteSrc('data:base64,image/png,abc')).toBe(
- 'data:base64,image/png,abc'
- );
+describe('Absolute src should behave as expected', () => {
+ test('Get localhost:8080', () => {
+ expect(getAbsoluteSrc('http://localhost:8080')).toBe(
+ 'http://localhost:8080/'
+ );
+ });
+ test('Get localhost/hi', () => {
+ expect(getAbsoluteSrc('/hi')).toBe('http://localhost/hi');
+ });
+ test('Get data:base64', () => {
+ expect(getAbsoluteSrc('data:base64,image/png,abc')).toBe(
+ 'data:base64,image/png,abc'
+ );
+ });
});
diff --git a/packages/core/src/test/composition-rules.test.tsx b/packages/core/src/test/composition-rules.test.tsx
index 873d24208a..8428863471 100644
--- a/packages/core/src/test/composition-rules.test.tsx
+++ b/packages/core/src/test/composition-rules.test.tsx
@@ -6,78 +6,81 @@ import {expectToThrow} from './expect-to-throw';
const AnyComp: React.FC = () => null;
-test('It should report invalid component id', () => {
- expectToThrow(
- () =>
- render(
- <Composition
- lazyComponent={() => Promise.resolve({default: AnyComp})}
- durationInFrames={100}
- fps={30}
- height={100}
- id="invalid@id"
- width={100}
- />
- ),
- /can only contain/
- );
-});
-
-test('It should validate the component id', () => {
- expect(() =>
- render(
- <Composition
- lazyComponent={() => Promise.resolve({default: AnyComp})}
- durationInFrames={100}
- fps={30}
- height={100}
- id="valid-id"
- width={100}
- />
- )
- ).not.toThrow();
-});
-
-test('It should throw if no id is passed', () => {
- expectToThrow(
- () =>
- render(
- // @ts-expect-error
- <Composition
- lazyComponent={() => Promise.resolve({default: AnyComp})}
- durationInFrames={100}
- fps={30}
- height={100}
- width={100}
- />
- ),
- /No id for composition passed./
- );
-});
-
-test('It should throw if multiple components have the same id', () => {
- expectToThrow(
- () =>
- render(
- <RemotionRoot>
+describe('Render composition-rules should throw with invalid props', () => {
+ test('It should report invalid component id', () => {
+ expectToThrow(
+ () =>
+ render(
<Composition
lazyComponent={() => Promise.resolve({default: AnyComp})}
durationInFrames={100}
fps={30}
height={100}
+ id="invalid@id"
width={100}
- id="id"
/>
+ ),
+ /can only contain/
+ );
+ });
+
+ test('It should throw if no id is passed', () => {
+ expectToThrow(
+ () =>
+ render(
+ // @ts-expect-error
<Composition
lazyComponent={() => Promise.resolve({default: AnyComp})}
durationInFrames={100}
fps={30}
height={100}
width={100}
- id="id"
/>
- </RemotionRoot>
- ),
- /Multiple composition with id id/
- );
+ ),
+ /No id for composition passed./
+ );
+ });
+
+ test('It should throw if multiple components have the same id', () => {
+ expectToThrow(
+ () =>
+ render(
+ <RemotionRoot>
+ <Composition
+ lazyComponent={() => Promise.resolve({default: AnyComp})}
+ durationInFrames={100}
+ fps={30}
+ height={100}
+ width={100}
+ id="id"
+ />
+ <Composition
+ lazyComponent={() => Promise.resolve({default: AnyComp})}
+ durationInFrames={100}
+ fps={30}
+ height={100}
+ width={100}
+ id="id"
+ />
+ </RemotionRoot>
+ ),
+ /Multiple composition with id id/
+ );
+ });
+});
+describe('Render composition-rules should not with valid props', () => {
+ test('It should validate the component id', () => {
+ expect(() =>
+ render(
+ <Composition
+ lazyComponent={() => Promise.resolve({default: AnyComp})}
+ durationInFrames={100}
+ fps={30}
+ height={100}
+ id="valid-id"
+ width={100}
+ />
+ )
+ ).not.toThrow();
+ });
});
diff --git a/packages/core/src/test/composition-validation.test.tsx b/packages/core/src/test/composition-validation.test.tsx
index da8092202f..e462c191a9 100644
--- a/packages/core/src/test/composition-validation.test.tsx
+++ b/packages/core/src/test/composition-validation.test.tsx
@@ -6,347 +6,363 @@ import {expectToThrow} from './expect-to-throw';
const AnyComp: React.FC = () => null;
-test('It should throw if multiple components have the same id', () => {
- expectToThrow(
- () =>
- render(
- <RemotionRoot>
- {/**
- // @ts-expect-error*/}
- <Composition
- lazyComponent={() => Promise.resolve({default: AnyComp})}
- durationInFrames={100}
- fps={30}
- height={100}
- id="id"
- />
- </RemotionRoot>
- ),
- /The "width/
- );
-});
-test('It should throw if height is a negative number', () => {
- expectToThrow(
- () =>
- render(
- <RemotionRoot>
- <Composition
- lazyComponent={() => Promise.resolve({default: AnyComp})}
- durationInFrames={100}
- fps={30}
- height={-100}
- width={100}
- id="id"
- />
- </RemotionRoot>
- ),
- /The "height" of a composition must be positive, but got -100./
- );
+describe('Composition-validation render should throw with invalid props', () => {
+ test('It should throw if multiple components have the same id', () => {
+ expectToThrow(
+ () =>
+ render(
+ <RemotionRoot>
+ {/**
+ // @ts-expect-error*/}
+ <Composition
+ lazyComponent={() => Promise.resolve({default: AnyComp})}
+ durationInFrames={100}
+ fps={30}
+ height={100}
+ id="id"
+ />
+ </RemotionRoot>
+ ),
+ /The "width/
+ );
+ });
+ describe('Throw with invalid height props', () => {
+ test('It should throw if height is a negative number', () => {
+ expectToThrow(
+ () =>
+ render(
+ <RemotionRoot>
+ <Composition
+ lazyComponent={() => Promise.resolve({default: AnyComp})}
+ durationInFrames={100}
+ fps={30}
+ height={-100}
+ width={100}
+ id="id"
+ />
+ </RemotionRoot>
+ ),
+ /The "height" of a composition must be positive, but got -100./
+ );
+ });
+ test('It should throw if height=0 is boundary off-point', () => {
+ expectToThrow(
+ () =>
+ render(
+ <RemotionRoot>
+ <Composition
+ lazyComponent={() => Promise.resolve({default: AnyComp})}
+ durationInFrames={100}
+ fps={30}
+ height={0}
+ width={100}
+ id="id"
+ />
+ </RemotionRoot>
+ ),
+ /The "height" of a composition must be positive, but got 0./
+ );
+ });
+ test('It should throw if height is not a number', () => {
+ expectToThrow(
+ () =>
+ render(
+ <RemotionRoot>
+ <Composition
+ lazyComponent={() => Promise.resolve({default: AnyComp})}
+ durationInFrames={100}
+ fps={30}
+ // @ts-expect-error
+ height={'100'}
+ width={100}
+ id="id"
+ />
+ </RemotionRoot>
+ ),
+ /The "height" of a composition must be a number, but you passed a string/
+ );
+ });
+ });
+ describe('Throw with invalid width props', () => {
+ test('It should throw if width is a negative number', () => {
+ expectToThrow(
+ () =>
+ render(
+ <RemotionRoot>
+ <Composition
+ lazyComponent={() => Promise.resolve({default: AnyComp})}
+ durationInFrames={100}
+ fps={30}
+ height={100}
+ width={-100}
+ id="id"
+ />
+ </RemotionRoot>
+ ),
+ /The "width" of a composition must be positive, but got -100./
+ );
+ });
+ test('It should throw if width=0 is boundary off-point', () => {
+ expectToThrow(
+ () =>
+ render(
+ <RemotionRoot>
+ <Composition
+ lazyComponent={() => Promise.resolve({default: AnyComp})}
+ durationInFrames={100}
+ fps={30}
+ height={100}
+ width={0}
+ id="id"
+ />
+ </RemotionRoot>
+ ),
+ /The "width" of a composition must be positive, but got 0./
+ );
+ });
+ test('It should throw if width is not a number', () => {
+ expectToThrow(
+ () =>
+ render(
+ <RemotionRoot>
+ <Composition
+ lazyComponent={() => Promise.resolve({default: AnyComp})}
+ durationInFrames={100}
+ fps={30}
+ height={100}
+ // @ts-expect-error
+ width={'100'}
+ id="id"
+ />
+ </RemotionRoot>
+ ),
+ /The "width" of a composition must be a number, but you passed a string/
+ );
+ });
+ });
+ describe('Throw with invalid durationInFrames', () => {
+ test('It should throw if durationInFrames of a composition is a negative number', () => {
+ expectToThrow(
+ () =>
+ render(
+ <RemotionRoot>
+ <Composition
+ lazyComponent={() => Promise.resolve({default: AnyComp})}
+ durationInFrames={-100}
+ fps={30}
+ height={100}
+ width={100}
+ id="id"
+ />
+ </RemotionRoot>
+ ),
+ /The "durationInFrames" of a composition must be positive, but got -100./
+ );
+ });
+ test('It should throw if durationInFrames=0 of a composition is boundary off-point', () => {
+ expectToThrow(
+ () =>
+ render(
+ <RemotionRoot>
+ <Composition
+ lazyComponent={() => Promise.resolve({default: AnyComp})}
+ durationInFrames={0}
+ fps={30}
+ height={100}
+ width={100}
+ id="id"
+ />
+ </RemotionRoot>
+ ),
+ /The "durationInFrames" of a composition must be positive, but got 0./
+ );
+ });
+ test('It should throw if durationInFrames of a composition is not an integer', () => {
+ expectToThrow(
+ () =>
+ render(
+ <RemotionRoot>
+ <Composition
+ lazyComponent={() => Promise.resolve({default: AnyComp})}
+ durationInFrames={0.11}
+ fps={30}
+ height={100}
+ width={100}
+ id="id"
+ />
+ </RemotionRoot>
+ ),
+ /The "durationInFrames" of a composition must be an integer, but got 0.11./
+ );
+ });
+ test('It should throw if durationInFrames of a composition is not a number', () => {
+ expectToThrow(
+ () =>
+ render(
+ <RemotionRoot>
+ <Composition
+ lazyComponent={() => Promise.resolve({default: AnyComp})}
+ // @ts-expect-error
+ durationInFrames={'100'}
+ fps={30}
+ height={100}
+ width={100}
+ id="id"
+ />
+ </RemotionRoot>
+ ),
+ /The "durationInFrames" of a composition must be a number, but you passed a string/
+ );
+ });
+ });
+ describe('Throw with invalid fps', () => {
+ test('It should throw if fps is of a composition is negative', () => {
+ expectToThrow(
+ () =>
+ render(
+ <RemotionRoot>
+ <Composition
+ lazyComponent={() => Promise.resolve({default: AnyComp})}
+ durationInFrames={100}
+ fps={-30}
+ height={100}
+ width={100}
+ id="id"
+ />
+ </RemotionRoot>
+ ),
+ /"fps" must be positive, but got -30./
+ );
+ });
+ test('It should throw if fps=0 of a composition is boundary off-point', () => {
+ expectToThrow(
+ () =>
+ render(
+ <RemotionRoot>
+ <Composition
+ lazyComponent={() => Promise.resolve({default: AnyComp})}
+ durationInFrames={100}
+ fps={0}
+ height={100}
+ width={100}
+ id="id"
+ />
+ </RemotionRoot>
+ ),
+ /"fps" must be positive, but got 0./
+ );
+ });
+
+ test('It should throw if fps of a composition is not a number', () => {
+ expectToThrow(
+ () =>
+ render(
+ <RemotionRoot>
+ <Composition
+ lazyComponent={() => Promise.resolve({default: AnyComp})}
+ durationInFrames={100}
+ // @ts-expect-error
+ fps={'30'}
+ height={100}
+ width={100}
+ id="id"
+ />
+ </RemotionRoot>
+ ),
+ /"fps" must be a number, but you passed a string/
+ );
+ });
+ });
});
-test('It should throw if height=0 is boundary off-point', () => {
- expectToThrow(
- () =>
- render(
- <RemotionRoot>
+
+describe('Composition-validation render should NOT throw with valid props', () => {
+ describe('Not throw with valid height props', () => {
+ test('It should not throw if height is a positive number', () => {
+ expect(() =>
+ render(
<Composition
lazyComponent={() => Promise.resolve({default: AnyComp})}
durationInFrames={100}
fps={30}
- height={0}
+ height={100}
width={100}
id="id"
/>
- </RemotionRoot>
- ),
- /The "height" of a composition must be positive, but got 0./
- );
-});
-test('It should not throw if height is a positive number', () => {
- expect(() =>
- render(
- <Composition
- lazyComponent={() => Promise.resolve({default: AnyComp})}
- durationInFrames={100}
- fps={30}
- height={100}
- width={100}
- id="id"
- />
- )
- ).not.toThrow();
-});
-test('It should not throw if height=1 is boundary on-point', () => {
- expect(() =>
- render(
- <Composition
- lazyComponent={() => Promise.resolve({default: AnyComp})}
- durationInFrames={100}
- fps={30}
- height={1}
- width={100}
- id="id"
- />
- )
- ).not.toThrow();
-});
-test('It should throw if height is not a number', () => {
- expectToThrow(
- () =>
- render(
- <RemotionRoot>
+ )
+ ).not.toThrow();
+ });
+ test('It should not throw if height=1 is boundary on-point', () => {
+ expect(() =>
+ render(
<Composition
lazyComponent={() => Promise.resolve({default: AnyComp})}
durationInFrames={100}
fps={30}
- // @ts-expect-error
- height={'100'}
+ height={1}
width={100}
id="id"
/>
- </RemotionRoot>
- ),
- /The "height" of a composition must be a number, but you passed a string/
- );
-});
+ )
+ ).not.toThrow();
+ });
+ });
-test('It should throw if width is a negative number', () => {
- expectToThrow(
- () =>
- render(
- <RemotionRoot>
+ describe('Not throw with valid width props', () => {
+ test('It should not throw if width is a positive number', () => {
+ expect(() =>
+ render(
<Composition
lazyComponent={() => Promise.resolve({default: AnyComp})}
durationInFrames={100}
fps={30}
height={100}
- width={-100}
- id="id"
- />
- </RemotionRoot>
- ),
- /The "width" of a composition must be positive, but got -100./
- );
-});
-test('It should throw if width=0 is boundary off-point', () => {
- expectToThrow(
- () =>
- render(
- <RemotionRoot>
- <Composition
- lazyComponent={() => Promise.resolve({default: AnyComp})}
- durationInFrames={100}
- fps={30}
- height={100}
- width={0}
- id="id"
- />
- </RemotionRoot>
- ),
- /The "width" of a composition must be positive, but got 0./
- );
-});
-test('It should not throw if width is a positive number', () => {
- expect(() =>
- render(
- <Composition
- lazyComponent={() => Promise.resolve({default: AnyComp})}
- durationInFrames={100}
- fps={30}
- height={100}
- width={100}
- id="id"
- />
- )
- ).not.toThrow();
-});
-test('It should not throw if width=1 is boundary on-point', () => {
- expect(() =>
- render(
- <Composition
- lazyComponent={() => Promise.resolve({default: AnyComp})}
- durationInFrames={100}
- fps={30}
- height={100}
- width={1}
- id="id"
- />
- )
- ).not.toThrow();
-});
-test('It should throw if width is not a number', () => {
- expectToThrow(
- () =>
- render(
- <RemotionRoot>
- <Composition
- lazyComponent={() => Promise.resolve({default: AnyComp})}
- durationInFrames={100}
- fps={30}
- height={100}
- // @ts-expect-error
- width={'100'}
- id="id"
- />
- </RemotionRoot>
- ),
- /The "width" of a composition must be a number, but you passed a string/
- );
-});
-
-test('It should throw if durationInFrames of a composition is a negative number', () => {
- expectToThrow(
- () =>
- render(
- <RemotionRoot>
- <Composition
- lazyComponent={() => Promise.resolve({default: AnyComp})}
- durationInFrames={-100}
- fps={30}
- height={100}
- width={100}
- id="id"
- />
- </RemotionRoot>
- ),
- /The "durationInFrames" of a composition must be positive, but got -100./
- );
-});
-test('It should throw if durationInFrames=0 of a composition is boundary off-point', () => {
- expectToThrow(
- () =>
- render(
- <RemotionRoot>
- <Composition
- lazyComponent={() => Promise.resolve({default: AnyComp})}
- durationInFrames={0}
- fps={30}
- height={100}
width={100}
id="id"
/>
- </RemotionRoot>
- ),
- /The "durationInFrames" of a composition must be positive, but got 0./
- );
-});
-test('It should throw if durationInFrames of a composition is not an integer', () => {
- expectToThrow(
- () =>
- render(
- <RemotionRoot>
- <Composition
- lazyComponent={() => Promise.resolve({default: AnyComp})}
- durationInFrames={0.11}
- fps={30}
- height={100}
- width={100}
- id="id"
- />
- </RemotionRoot>
- ),
- /The "durationInFrames" of a composition must be an integer, but got 0.11./
- );
-});
-test('It should not throw if durationInFrames=1 of a composition is boundary on-point', () => {
- expect(() =>
- render(
- <Composition
- lazyComponent={() => Promise.resolve({default: AnyComp})}
- durationInFrames={1}
- fps={30}
- height={100}
- width={100}
- id="id"
- />
- )
- ).not.toThrow();
-});
-test('It should throw if durationInFrames of a composition is not a number', () => {
- expectToThrow(
- () =>
- render(
- <RemotionRoot>
- <Composition
- lazyComponent={() => Promise.resolve({default: AnyComp})}
- // @ts-expect-error
- durationInFrames={'100'}
- fps={30}
- height={100}
- width={100}
- id="id"
- />
- </RemotionRoot>
- ),
- /The "durationInFrames" of a composition must be a number, but you passed a string/
- );
-});
-
-test('It should throw if fps is of a composition is negative', () => {
- expectToThrow(
- () =>
- render(
- <RemotionRoot>
+ )
+ ).not.toThrow();
+ });
+ test('It should not throw if width=1 is boundary on-point', () => {
+ expect(() =>
+ render(
<Composition
lazyComponent={() => Promise.resolve({default: AnyComp})}
durationInFrames={100}
- fps={-30}
+ fps={30}
height={100}
- width={100}
+ width={1}
id="id"
/>
- </RemotionRoot>
- ),
- /"fps" must be positive, but got -30./
- );
-});
-test('It should throw if fps=0 of a composition is boundary off-point', () => {
- expectToThrow(
- () =>
+ )
+ ).not.toThrow();
+ });
+ });
+ test('It should not throw if durationInFrames=1 of a composition is boundary on-point', () => {
+ expect(() =>
render(
- <RemotionRoot>
- <Composition
- lazyComponent={() => Promise.resolve({default: AnyComp})}
- durationInFrames={100}
- fps={0}
- height={100}
- width={100}
- id="id"
- />
- </RemotionRoot>
- ),
- /"fps" must be positive, but got 0./
- );
-});
-test('It should not throw if fps=1 of a composition is boundary on-point', () => {
- expect(() =>
- render(
- <Composition
- lazyComponent={() => Promise.resolve({default: AnyComp})}
- durationInFrames={100}
- fps={1}
- height={100}
- width={100}
- id="id"
- />
- )
- ).not.toThrow();
-});
-test('It should throw if fps of a composition is not a number', () => {
- expectToThrow(
- () =>
+ <Composition
+ lazyComponent={() => Promise.resolve({default: AnyComp})}
+ durationInFrames={1}
+ fps={30}
+ height={100}
+ width={100}
+ id="id"
+ />
+ )
+ ).not.toThrow();
+ });
+ test('It should not throw if fps=1 of a composition is boundary on-point', () => {
+ expect(() =>
render(
- <RemotionRoot>
- <Composition
- lazyComponent={() => Promise.resolve({default: AnyComp})}
- durationInFrames={100}
- // @ts-expect-error
- fps={'30'}
- height={100}
- width={100}
- id="id"
- />
- </RemotionRoot>
- ),
- /"fps" must be a number, but you passed a string/
- );
+ <Composition
+ lazyComponent={() => Promise.resolve({default: AnyComp})}
+ durationInFrames={100}
+ fps={1}
+ height={100}
+ width={100}
+ id="id"
+ />
+ )
+ ).not.toThrow();
+ });
});
diff --git a/packages/core/src/test/sequence-validation.test.tsx b/packages/core/src/test/sequence-validation.test.tsx
index 5ccb2e21c6..ba4b556df2 100644
--- a/packages/core/src/test/sequence-validation.test.tsx
+++ b/packages/core/src/test/sequence-validation.test.tsx
@@ -3,92 +3,84 @@ 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./
- );
-});
+describe('Composition-validation render should throw with invalid props', () => {
+ describe('Throw with invalid duration props', () => {
+ test('It should throw if Sequence has missing duration', () => {
+ expectToThrow(
+ // @ts-expect-error
+ () => render(<Sequence from={0} />),
+ /You passed to durationInFrames an argument of type undefined, but it must be a number./
+ );
+ });
+ 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./
+ );
+ });
+ 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 throw if Sequence has missing duration', () => {
- expectToThrow(
- // @ts-expect-error
- () => render(<Sequence from={0} />),
- /You passed to durationInFrames an argument of type undefined, but it must be a number./
- );
+ describe('Throw with invalid from props', () => {
+ 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 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(
+ () =>
+ 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/
+ );
+ });
});
-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./
- );
-});
-test('It should throw if Sequence has non-integer from', () => {
- expectToThrow(
- () =>
+describe('Composition-validation render should NOT throw with valid props', () => {
+ test('It should allow null as children', () => {
+ expect(() =>
render(
- <Sequence from={0.1} durationInFrames={1}>
- hi
+ <Sequence durationInFrames={100} from={0}>
+ {null}
</Sequence>
- ),
- /The "from" prop of a sequence must be an integer, but got 0.1./
- );
-});
-
-test('It should throw if Sequence has missing duration', () => {
- expectToThrow(
- () =>
+ )
+ ).not.toThrow();
+ });
+ test('It should allow undefined as children', () => {
+ expect(() =>
render(
- <Sequence from={0} durationInFrames={1.1}>
- hi
+ <Sequence durationInFrames={100} from={0}>
+ {undefined}
</Sequence>
- ),
- /The "durationInFrames" of a sequence must be an integer, but got 1.1./
- );
-});
-
-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(
- <Sequence durationInFrames={100} from={0}>
- {null}
- </Sequence>
- )
- ).not.toThrow();
-});
-
-test('It should allow undefined as children', () => {
- expect(() =>
- render(
- <Sequence durationInFrames={100} from={0}>
- {undefined}
- </Sequence>
- )
- ).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/
- );
+ )
+ ).not.toThrow();
+ });
});
diff --git a/packages/core/src/test/validate-start-from-props.test.ts b/packages/core/src/test/validate-start-from-props.test.ts
index c5953d1d7f..3bd6b8fe89 100644
--- a/packages/core/src/test/validate-start-from-props.test.ts
+++ b/packages/core/src/test/validate-start-from-props.test.ts
@@ -1,57 +1,63 @@
import {validateStartFromProps} from '../validate-start-from-props';
import {expectToThrow} from './expect-to-throw';
-test('It should throw if startFrom prop is negative', () => {
- expectToThrow(
- () => validateStartFromProps(-40, 1),
- /startFrom must be greater than equal to 0 instead got -40./
- );
-});
-
-test('It should throw if endAt prop is negative', () => {
- expectToThrow(
- () => validateStartFromProps(0, -40),
- /endAt must be a positive number, instead got -40./
- );
-});
-
-test('It should throw if endAt is less than startFrom', () => {
- expectToThrow(
- () => validateStartFromProps(10, 1),
- /endAt prop must be greater than startFrom prop./
- );
-});
+describe('ValidateStartFrom props should throw', () => {
+ describe('Throw with invalid startFrom prop', () => {
+ test('It should throw if startFrom prop is negative', () => {
+ expectToThrow(
+ () => validateStartFromProps(-40, 1),
+ /startFrom must be greater than equal to 0 instead got -40./
+ );
+ });
+ test('It should throw if startFrom is not a number', () => {
+ expectToThrow(
+ //@ts-expect-error
+ () => validateStartFromProps('10', 20),
+ /type of startFrom prop must be a number, instead got type string./
+ );
+ });
+ test('It should throw if startFrom is NaN', () => {
+ expectToThrow(
+ () => validateStartFromProps(NaN, 20),
+ /startFrom prop can not be NaN or Infinity./
+ );
+ });
+ test('It should throw if startFrom is Infinity', () => {
+ expectToThrow(
+ () => validateStartFromProps(Infinity, 20),
+ /startFrom prop can not be NaN or Infinity./
+ );
+ });
+ });
-test('It should throw if endAt is not a number', () => {
- expectToThrow(
- //@ts-expect-error
- () => validateStartFromProps(10, '20'),
- /type of endAt prop must be a number, instead got type string./
- );
-});
+ describe('Throw with invalid endAt prop', () => {
+ test('It should throw if endAt prop is negative', () => {
+ expectToThrow(
+ () => validateStartFromProps(0, -40),
+ /endAt must be a positive number, instead got -40./
+ );
+ });
-test('It should throw if startFrom is not a number', () => {
- expectToThrow(
- //@ts-expect-error
- () => validateStartFromProps('10', 20),
- /type of startFrom prop must be a number, instead got type string./
- );
-});
+ test('It should throw if endAt is less than startFrom', () => {
+ expectToThrow(
+ () => validateStartFromProps(10, 1),
+ /endAt prop must be greater than startFrom prop./
+ );
+ });
-test('It should throw if endAt is NaN', () => {
- expectToThrow(
- () => validateStartFromProps(10, NaN),
- /endAt prop can not be NaN./
- );
-});
+ test('It should throw if endAt is not a number', () => {
+ expectToThrow(
+ //@ts-expect-error
+ () => validateStartFromProps(10, '20'),
+ /type of endAt prop must be a number, instead got type string./
+ );
+ });
-test('It should throw if startFrom is NaN or Infinity', () => {
- expectToThrow(
- () => validateStartFromProps(NaN, 20),
- /startFrom prop can not be NaN or Infinity./
- );
- expectToThrow(
- () => validateStartFromProps(Infinity, 20),
- /startFrom prop can not be NaN or Infinity./
- );
+ test('It should throw if endAt is NaN', () => {
+ expectToThrow(
+ () => validateStartFromProps(10, NaN),
+ /endAt prop can not be NaN./
+ );
+ });
+ });
});