Skip to content

🎥 Make videos programmatically with React

Added property test for playbackRate to Player

bpedersen762d2b1e21a5
diff --git a/packages/player/src/Player.tsx b/packages/player/src/Player.tsx
index 1eb7c573bf..60177e0697 100644
--- a/packages/player/src/Player.tsx
+++ b/packages/player/src/Player.tsx
@@ -196,7 +196,7 @@ export const PlayerFn = <T,>(
if (playbackRate < -4 || playbackRate > 4 || playbackRate % 1 !== 0) {
throw new TypeError(
- `'playbackRate' must be an integer within the bounds of -4 and 4`
+ "'playbackRate' must be an integer within the bounds of -4 and 4"
);
}
diff --git a/packages/player/src/test/validate-prop.test.tsx b/packages/player/src/test/validate-prop.test.tsx
index 4806e79fac..4753e5328a 100644
--- a/packages/player/src/test/validate-prop.test.tsx
+++ b/packages/player/src/test/validate-prop.test.tsx
@@ -104,6 +104,28 @@ test('No durationInFrames should give errors', () => {
}
});
+test.each([-5, 1.3])('Invalid playbackRate should give error', () => {
+ try {
+ render(
+ <Player
+ compositionWidth={500}
+ compositionHeight={400}
+ fps={30}
+ durationInFrames={500}
+ component={HelloWorld}
+ controls
+ showVolumeControls
+ // @ts-expect-error
+ playbackRate={-5}
+ />
+ );
+ } catch (e) {
+ expect((e as Error).message).toMatch(
+ /'playbackRate' must be an integer within the bounds of -4 and 4/
+ );
+ }
+});
+
test.each([
['controls'],
['loop'],