🎥 Make videos programmatically with React
remove some test smells
Calvin Falter7533877f4cc9
diff --git a/packages/core/src/test/crf.test.ts b/packages/core/src/test/crf.test.tsindex 25950a761b..c736ae8741 100644--- a/packages/core/src/test/crf.test.ts+++ b/packages/core/src/test/crf.test.ts@@ -8,7 +8,7 @@ import {} from '../config/crf';import {expectToThrow} from './expect-to-throw';-test('crf tests getDefaultCrfForCodec', () => {+test('crf tests getDefaultCrfForCodec valid input', () => {// input codec, outputconst valuesA: [Codec, number][] = [['h264', 18],@@ -19,7 +19,9 @@ test('crf tests getDefaultCrfForCodec', () => {valuesA.forEach((entry) =>expect(getDefaultCrfForCodec(entry[0])).toEqual(entry[1]));+});+test('crf tests getDefaultCrfForCodec invalid input', () => {// input codecconst valuesB = ['abc', '', 3, undefined];valuesB.forEach((entry) =>@@ -31,7 +33,7 @@ test('crf tests getDefaultCrfForCodec', () => {);});-test('crf tests getValidCrfRanges', () => {+test('crf tests getValidCrfRanges valid input', () => {// input crf, input codec, valid rangeconst valuesA: [Codec, [number, number]][] = [['h264', [0, 51]],@@ -42,7 +44,9 @@ test('crf tests getValidCrfRanges', () => {valuesA.forEach((entry) =>expect(getValidCrfRanges(entry[0])).toEqual(entry[1]));+});+test('crf tests getValidCrfRanges invalid input', () => {// input codecconst valuesB = ['abc', '', 3, undefined];valuesB.forEach((entry) =>@@ -54,7 +58,7 @@ test('crf tests getValidCrfRanges', () => {);});-test('validateSelectedCrfAndCodecCombination', () => {+test('validateSelectedCrfAndCodecCombination valid input', () => {// input crf, input codecconst valuesA: [number, Codec][] = [[20, 'h264'],@@ -75,7 +79,9 @@ test('validateSelectedCrfAndCodecCombination', () => {validateSelectedCrfAndCodecCombination(entry[0], entry[1])).not.toThrow());+});+test('validateSelectedCrfAndCodecCombination invalid input', () => {// input crf, input codec, valid rangeconst valuesB: [number, Codec, [number, number]][] = [[80, 'h264', [0, 51]],@@ -101,7 +107,7 @@ test('validateSelectedCrfAndCodecCombination', () => {);});-test('get crf', () => {+test('get crf valid input', () => {// input crf, input codec, output crfconst valuesA: [number | undefined, Codec, number][] = [[20, 'h264', 20],@@ -117,7 +123,9 @@ test('get crf', () => {setCrf(entry[0]);expect(getActualCrf(entry[1])).toEqual(entry[2]);});+});+test('get crf invalid input', () => {// input crf, input codec, valid rangeconst valuesB: [number, Codec, [number, number]][] = [[80, 'h264', [0, 51]],diff --git a/packages/core/src/test/interpolate.test.ts b/packages/core/src/test/interpolate.test.tsindex d1d5c4d859..71f3f6b27d 100644--- a/packages/core/src/test/interpolate.test.ts+++ b/packages/core/src/test/interpolate.test.ts@@ -90,34 +90,43 @@ test('Easing test', () => {});test('Extrapolation left test', () => {- expect(- interpolate(-3, [0, 1, 2], [0, 0.5, 1], {- extrapolateRight: 'extend',- })- ).toEqual(-1.5);- expect(interpolate(-3, [0, 1, 2], [0, 0.5, 1])).toEqual(-1.5);+ const testValues: ('extend' | undefined)[] = ['extend', undefined];+ testValues.forEach((entry) => {+ expect(+ interpolate(-3, [0, 1, 2], [0, 0.5, 1], {+ extrapolateRight: entry,+ })+ ).toEqual(-1.5);+ });});test('Extrapolation right test', () => {- expect(- interpolate(3, [0, 1, 2], [0, 0.5, 1], {- extrapolateRight: 'extend',- })- ).toEqual(1.5);- expect(interpolate(3, [0, 1, 2], [0, 0.5, 1])).toEqual(1.5);+ const testValues: ('extend' | undefined)[] = ['extend', undefined];+ testValues.forEach((entry) => {+ expect(+ interpolate(3, [0, 1, 2], [0, 0.5, 1], {+ extrapolateRight: entry,+ })+ ).toEqual(1.5);+ });});test('Extrapolation identity', () => {- expect(- interpolate(1000, [0, 1, 2], [0, 2, 4], {- extrapolateRight: 'identity',- })- ).toBe(1000);- expect(- interpolate(-1000, [0, 1, 2], [0, 2, 4], {- extrapolateLeft: 'identity',- })- ).toBe(-1000);+ const testValues: [+ number,+ {+ extrapolateRight?: 'identity' | undefined;+ extrapolateLeft?: 'identity' | undefined;+ }+ ][] = [+ [1000, {extrapolateRight: 'identity'}],+ [-1000, {extrapolateLeft: 'identity'}],+ ];+ testValues.forEach((entry) => {+ expect(interpolate(entry[0], [0, 1, 2], [0, 2, 4], entry[1])).toBe(+ entry[0]+ );+ });});test('Clamp right test', () => {@@ -137,16 +146,18 @@ test('Clamp left test', () => {});test('Zig-zag test', () => {- expect(interpolate(3.5, [1, 2, 3, 4, 5], [0, 1000, 0, -1000, 1000])).toBe(- -500- );- expect(interpolate(4, [1, 2, 3, 4, 5], [0, 1000, 0, -1000, 1000])).toBe(- -1000- );- expect(interpolate(6, [1, 2, 3, 4, 5], [0, 1000, 0, -1000, 1000])).toBe(3000);- expect(interpolate(-0.1, [1, 2, 3, 4, 5], [0, 1000, 0, -1000, 1000])).toBe(- -1100- );+ const testValues: [number, number][] = [+ [3.5, -500],+ [4, -1000],+ [6, 3000],+ [-0.1, -1100],+ ];++ testValues.forEach((entry) => {+ expect(+ interpolate(entry[0], [1, 2, 3, 4, 5], [0, 1000, 0, -1000, 1000])+ ).toBe(entry[1]);+ });});test('Handle bad types', () => {diff --git a/packages/core/src/test/quality.test.ts b/packages/core/src/test/quality.test.tsindex 6a74b6eaa4..2c8f73b991 100644--- a/packages/core/src/test/quality.test.ts+++ b/packages/core/src/test/quality.test.ts@@ -1,7 +1,7 @@import {getQuality, setQuality} from '../config/quality';import {expectToThrow} from './expect-to-throw';-test('set quality tests', () => {+test('set quality tests valid input', () => {// input qualityconst valuesA = [50, undefined, 100, 1];valuesA.forEach((entry) => {@@ -15,7 +15,9 @@ test('set quality tests', () => {setQuality(entry[0]);expect(getQuality()).toEqual(entry[1]);});+});+test('set quality tests invalid input', () => {// input qualityconst valuesC = ['abc', null];valuesC.forEach((entry) =>