🎥 Make videos programmatically with React
test stitcher
Jonny Burger58e4d3293f5e
diff --git a/packages/renderer/src/stitcher.ts b/packages/renderer/src/stitcher.tsindex 040fae2ab7..d5b38a83d4 100644--- a/packages/renderer/src/stitcher.ts+++ b/packages/renderer/src/stitcher.ts@@ -43,6 +43,17 @@ export const stitchFramesToVideo = async (options: {proResProfile?: ProResProfile;verbose?: boolean;}): Promise<void> => {+ Internals.validateDimension(+ options.height,+ 'height',+ 'passed to `stitchFramesToVideo()`'+ );+ Internals.validateDimension(+ options.width,+ 'width',+ 'passed to `stitchFramesToVideo()`'+ );+ Internals.validateFps(options.fps, 'passed to `stitchFramesToVideo()`');const codec = options.codec ?? Internals.DEFAULT_CODEC;const crf = options.crf ?? Internals.getDefaultCrfForCodec(codec);const imageFormat = options.imageFormat ?? DEFAULT_IMAGE_FORMAT;diff --git a/packages/renderer/src/test/validate-config-stitcher.test.ts b/packages/renderer/src/test/validate-config-stitcher.test.tsnew file mode 100644index 0000000000..d7247588e6--- /dev/null+++ b/packages/renderer/src/test/validate-config-stitcher.test.ts@@ -0,0 +1,41 @@+import {stitchFramesToVideo} from '../stitcher';++describe('Should validate invalid data passed to stitchFramesToVideo', () => {+ test('Invalid FPS', () => {+ return expect(() =>+ // @ts-expect-error+ stitchFramesToVideo({+ fps: -1,+ height: 1000,+ width: 1000,+ })+ ).rejects.toThrow(+ /"fps" must be positive, but got -1 passed to `stitchFramesToVideo\(\)`/+ );+ });++ test('Invalid height', async () => {+ return expect(+ // @ts-expect-error+ stitchFramesToVideo({+ fps: 30,+ height: 1000.5,+ width: 1000,+ })+ ).rejects.toThrow(+ /The "height" prop passed to `stitchFramesToVideo\(\)` must be an integer, but is 1000.5./+ );+ });+ test('Invalid width', async () => {+ return expect(+ // @ts-expect-error+ stitchFramesToVideo({+ fps: 30,+ width: 1000.5,+ height: 1000,+ })+ ).rejects.toThrow(+ /The "width" prop passed to `stitchFramesToVideo\(\)` must be an integer, but is 1000.5./+ );+ });+});