🎥 Make videos programmatically with React
image-format test improvements
Jonas Brunner2bb6aeaf8deb
diff --git a/packages/core/src/config/image-format.ts b/packages/core/src/config/image-format.tsindex 39af05b40f..afc9f99b46 100644--- a/packages/core/src/config/image-format.ts+++ b/packages/core/src/config/image-format.ts@@ -21,12 +21,13 @@ export const getUserPreferredImageFormat = () => {return currentImageFormat;};+// By returning a value, we improve testability as we can specifically test certain branchesexport const validateSelectedPixelFormatAndImageFormatCombination = (pixelFormat: PixelFormat,imageFormat: ImageFormat-) => {+): 'none' | 'valid' => {if (imageFormat === 'none') {- return;+ return 'none';}if (!validOptions.includes(imageFormat)) {throw new TypeError(@@ -34,11 +35,12 @@ export const validateSelectedPixelFormatAndImageFormatCombination = ();}if (pixelFormat !== 'yuva420p') {- return;+ return 'valid';}if (imageFormat !== 'png') {throw new TypeError("Pixel format was set to 'yuva420p' but the image format is not PNG. To render transparent videos, you need to set PNG as the image format.");}+ return 'valid';};diff --git a/packages/core/src/test/image-format.test.ts b/packages/core/src/test/image-format.test.tsindex 770d46a8e3..5f3b86ed98 100644--- a/packages/core/src/test/image-format.test.ts+++ b/packages/core/src/test/image-format.test.ts@@ -51,23 +51,23 @@ test('Special case - invalid combination with pixel ("yuva420p") and image forma);});test('Special case - valid combination with pixel ("yuva420p") and image format ("png") should not throw', () => {- expect(() =>+ expect(validateSelectedPixelFormatAndImageFormatCombination('yuva420p', 'png')- ).not.toThrow();+ ).toEqual('valid');});test('Valid combination with pixel and image format ("png") should not throw', () => {- expect(() =>+ expect(validateSelectedPixelFormatAndImageFormatCombination('yuv420p', 'png')- ).not.toThrow();+ ).toEqual('valid');});test('Valid combination with pixel and image format ("jpeg") should not throw', () => {- expect(() =>+ expect(validateSelectedPixelFormatAndImageFormatCombination('yuv420p', 'jpeg')- ).not.toThrow();+ ).toEqual('valid');});test('"none" as image format should not throw', () => {- expect(() =>+ expect(validateSelectedPixelFormatAndImageFormatCombination('yuv420p', 'none')- ).not.toThrow();+ ).toEqual('none');});