Skip to content

🎥 Make videos programmatically with React

add media validation tests

Jonny Burger4038a0505255
diff --git a/packages/core/src/test/media-validation.test.tsx b/packages/core/src/test/media-validation.test.tsx
index 3bd2670d0b..1f672a8483 100644
--- a/packages/core/src/test/media-validation.test.tsx
+++ b/packages/core/src/test/media-validation.test.tsx
@@ -40,3 +40,27 @@ describe('ValidateMediaProps should not throw with valid volume inputs', () => {
})
);
});
+
+describe('ValidateMediaProps should throw with invalid playbackRate', () => {
+ test(`It should not allow playbackRate of 0 or below.`, () => {
+ expectToThrow(
+ () => validateMediaProps({playbackRate: -1}, 'Audio'),
+ /You have passed a playbackRate of -1 to your <Audio \/> component. Playback rate must be a real number above 0./
+ );
+ });
+ test(`It should not allow non-finite playbackRate.`, () => {
+ expectToThrow(
+ () => validateMediaProps({playbackRate: Infinity}, 'Audio'),
+ /You have passed a playbackRate of Infinity to your <Audio \/> component. Playback rate must be a real number above 0./
+ );
+ });
+ test(`It should not allow NaN playbackRate.`, () => {
+ expectToThrow(
+ () => validateMediaProps({playbackRate: NaN}, 'Audio'),
+ /You have passed a playbackRate of NaN to your <Audio \/> component. Playback rate must be a real number above 0./
+ );
+ });
+ test(`It should not allow regular playbackrate.`, () => {
+ expect(() => validateMediaProps({playbackRate: 1}, 'Audio')).not.toThrow();
+ });
+});