Skip to content

🎥 Make videos programmatically with React

validation test fixes

Jonny Burgercda45d29300a
diff --git a/packages/core/src/Composition.tsx b/packages/core/src/Composition.tsx
index e519ae8cc9..e6adb6aa92 100644
--- a/packages/core/src/Composition.tsx
+++ b/packages/core/src/Composition.tsx
@@ -59,7 +59,10 @@ export const Composition = <T,>({
validateDimension(width, 'width', 'Composition');
validateDimension(height, 'height', 'Composition');
- validateDurationInFrames(durationInFrames);
+ validateDurationInFrames(
+ durationInFrames,
+ 'of the <Composition/> component'
+ );
validateFps(fps);
registerComposition<T>({
durationInFrames,
diff --git a/packages/core/src/validation/validate-duration-in-frames.ts b/packages/core/src/validation/validate-duration-in-frames.ts
index 88188c7baf..bfdfc56739 100644
--- a/packages/core/src/validation/validate-duration-in-frames.ts
+++ b/packages/core/src/validation/validate-duration-in-frames.ts
@@ -1,19 +1,22 @@
-export const validateDurationInFrames = (durationInFrames: number) => {
+export const validateDurationInFrames = (
+ durationInFrames: number,
+ component: string
+) => {
if (typeof durationInFrames !== 'number') {
throw new Error(
- `The "durationInFrames" prop of the <Composition/> component must be a number, but you passed a value of type ${typeof durationInFrames}`
+ `The "durationInFrames" prop ${component} must be a number, but you passed a value of type ${typeof durationInFrames}`
);
}
if (durationInFrames <= 0) {
throw new TypeError(
- `The "durationInFrames" prop of the <Composition/> component must be positive, but got ${durationInFrames}.`
+ `The "durationInFrames" prop ${component} must be positive, but got ${durationInFrames}.`
);
}
if (durationInFrames % 1 !== 0) {
throw new TypeError(
- `The "durationInFrames" prop of the <Composition/> component must be an integer, but got ${durationInFrames}.`
+ `The "durationInFrames" prop ${component} must be an integer, but got ${durationInFrames}.`
);
}
};
diff --git a/packages/player/src/Player.tsx b/packages/player/src/Player.tsx
index 57010b112e..198a05925e 100644
--- a/packages/player/src/Player.tsx
+++ b/packages/player/src/Player.tsx
@@ -100,7 +100,10 @@ export const PlayerFn = <T,>(
Internals.validateDimension(compositionHeight, 'compositionHeight', 'Player');
Internals.validateDimension(compositionWidth, 'compositionWidth', 'Player');
- Internals.validateDurationInFrames(durationInFrames);
+ Internals.validateDurationInFrames(
+ durationInFrames,
+ 'of the <Player/> component'
+ );
Internals.validateFps(fps);
if (typeof controls !== 'boolean' && typeof controls !== 'undefined') {
diff --git a/packages/player/src/test/validate-prop.test.tsx b/packages/player/src/test/validate-prop.test.tsx
index 98b3f13ee9..86d6ba30f5 100644
--- a/packages/player/src/test/validate-prop.test.tsx
+++ b/packages/player/src/test/validate-prop.test.tsx
@@ -99,7 +99,7 @@ test('No durationInFrames should give errors', () => {
);
} catch (e) {
expect(e.message).toMatch(
- /The "durationInFrames" of a composition must be a number, but you passed a value of type undefined/
+ /The "durationInFrames" prop of the <Player\/> component must be a number, but you passed a value of type undefined/
);
}
});