🎥 Make videos programmatically with React
Added tests for audio and video
Shankhadeep Deyeaac6c8a2ce3
diff --git a/packages/core/src/audio/Audio.tsx b/packages/core/src/audio/Audio.tsxindex d2a260fe66..91f080453a 100644--- a/packages/core/src/audio/Audio.tsx+++ b/packages/core/src/audio/Audio.tsx@@ -35,7 +35,7 @@ export const Audio: React.FC<RemotionAudioProps & RemotionMainAudioProps> = ();}if (isNaN(endAt)) {- throw new TypeError('startAt propcan not be NaN.');+ throw new TypeError('endAt prop can not be NaN.');}}if (typeof startAt !== 'undefined' && typeof endAt !== 'undefined') {diff --git a/packages/core/src/test/audio.test.tsx b/packages/core/src/test/audio.test.tsxnew file mode 100644index 0000000000..6fab28a203--- /dev/null+++ b/packages/core/src/test/audio.test.tsx@@ -0,0 +1,59 @@+import {render} from '@testing-library/react';+import React from 'react';+import {Audio} from '../audio';+import {expectToThrow} from './expect-to-throw';++test('It should throw if startAt prop is negative', () => {+ expectToThrow(+ () => render(<Audio startAt={-40} />),+ /startAt must be greater than equal to 0 instead got -40./+ );+});++test('It should throw if endAt prop is negative', () => {+ expectToThrow(+ () => render(<Audio endAt={-40} />),+ /endAt must be a positive number, instead got -40./+ );+});++test('It should throw if endAt is less than startAt', () => {+ expectToThrow(+ () => render(<Audio startAt={10} endAt={1} />),+ /endAt prop must be greater than startAt prop/+ );+});++test('It should throw if endAt is not a number', () => {+ expectToThrow(+ //@ts-expect-error+ () => render(<Audio endAt={'hey'} />),+ /type of endAt prop is a number, instead got type string./+ );+});++test('It should throw if startAt is not a number', () => {+ expectToThrow(+ //@ts-expect-error+ () => render(<Audio startAt={'hey'} />),+ /type of startAt prop is a number, instead got type string./+ );+});++test('It should throw if endAt is NaN', () => {+ expectToThrow(+ () => render(<Audio endAt={NaN} />),+ /endAt prop can not be NaN./+ );+});++test('It should throw if startAt is NaN or Infinity', () => {+ expectToThrow(+ () => render(<Audio startAt={NaN} />),+ /startAt prop can not be NaN or Infinity./+ );+ expectToThrow(+ () => render(<Audio startAt={Infinity} />),+ /startAt prop can not be NaN or Infinity./+ );+});diff --git a/packages/core/src/test/video.test.tsx b/packages/core/src/test/video.test.tsxnew file mode 100644index 0000000000..1a598e4c6f--- /dev/null+++ b/packages/core/src/test/video.test.tsx@@ -0,0 +1,59 @@+import {render} from '@testing-library/react';+import React from 'react';+import {Video} from '../video';+import {expectToThrow} from './expect-to-throw';++test('It should throw if startAt prop is negative', () => {+ expectToThrow(+ () => render(<Video startAt={-40} />),+ /startAt must be greater than equal to 0 instead got -40./+ );+});++test('It should throw if endAt prop is negative', () => {+ expectToThrow(+ () => render(<Video endAt={-40} />),+ /endAt must be a positive number, instead got -40./+ );+});++test('It should throw if endAt is less than startAt', () => {+ expectToThrow(+ () => render(<Video startAt={10} endAt={1} />),+ /endAt prop must be greater than startAt prop/+ );+});++test('It should throw if endAt is not a number', () => {+ expectToThrow(+ //@ts-expect-error+ () => render(<Video endAt={'hey'} />),+ /type of endAt prop is a number, instead got type string./+ );+});++test('It should throw if startAt is not a number', () => {+ expectToThrow(+ //@ts-expect-error+ () => render(<Video startAt={'hey'} />),+ /type of startAt prop is a number, instead got type string./+ );+});++test('It should throw if endAt is NaN', () => {+ expectToThrow(+ () => render(<Video endAt={NaN} />),+ /endAt prop can not be NaN./+ );+});++test('It should throw if startAt is NaN or Infinity', () => {+ expectToThrow(+ () => render(<Video startAt={NaN} />),+ /startAt prop can not be NaN or Infinity./+ );+ expectToThrow(+ () => render(<Video startAt={Infinity} />),+ /startAt prop can not be NaN or Infinity./+ );+});diff --git a/packages/core/src/video/Video.tsx b/packages/core/src/video/Video.tsxindex 28b0c2ac71..2dd9733e7f 100644--- a/packages/core/src/video/Video.tsx+++ b/packages/core/src/video/Video.tsx@@ -36,7 +36,7 @@ export const Video: React.FC<RemotionVideoProps & RemotionMainVideoProps> = ();}if (isNaN(endAt)) {- throw new TypeError('startAt propcan not be NaN.');+ throw new TypeError('endAt prop can not be NaN.');}}if (typeof startAt !== 'undefined' && typeof endAt !== 'undefined') {