🎥 Make videos programmatically with React
add test, change variable name `value` to `input`
Shankhadeep Deydcfe41b1d89d
diff --git a/packages/core/src/interpolateColors.ts b/packages/core/src/interpolateColors.tsindex 99dc0b8bf7..7aca23500b 100644--- a/packages/core/src/interpolateColors.ts+++ b/packages/core/src/interpolateColors.ts@@ -704,17 +704,35 @@ const interpolateColorsRGB = (};export const interpolateColors = (- value: number,+ input: number,inputRange: readonly number[],outputRange: readonly (string | number)[],colorSpace: 'RGB' | 'HSV' = 'RGB'): string => {+ if (+ typeof input === 'undefined' ||+ typeof inputRange === 'undefined' ||+ typeof outputRange === 'undefined'+ ) {+ throw new Error('input or inputRange or outputRange can not be undefined');+ }++ if (inputRange.length !== outputRange.length) {+ throw new Error(+ 'inputRange (' ++ inputRange.length ++ ') and outputRange (' ++ outputRange.length ++ ') must have the same length'+ );+ }+const processedOutputRange = outputRange.map((c) => processColor(c)!);if (colorSpace === 'HSV') {- return interpolateColorsHSV(value, inputRange, processedOutputRange);+ return interpolateColorsHSV(input, inputRange, processedOutputRange);}if (colorSpace === 'RGB') {- return interpolateColorsRGB(value, inputRange, processedOutputRange);+ return interpolateColorsRGB(input, inputRange, processedOutputRange);}throw new Error(`invalid color space provided: ${colorSpace}. Supported values are: ['RGB', 'HSV']`diff --git a/packages/core/src/test/interpolateColors.test.ts b/packages/core/src/test/interpolateColors.test.tsindex 458baa3434..8ea8434749 100644--- a/packages/core/src/test/interpolateColors.test.ts+++ b/packages/core/src/test/interpolateColors.test.ts@@ -6,4 +6,19 @@ test('Throws if color space is not right', () => {//@ts-expect-errorinterpolateColors(1, [0, 1], ['#ffaadd', '#fabgdf'], 'GFR');}, /invalid color space provided: GFR. Supported values are: \['RGB', 'HSV'\]/);++ expectToThrow(() => {+ //@ts-expect-error+ interpolateColors(undefined, undefined, undefined);+ }, /input or inputRange or outputRange can not be undefined/);++ expectToThrow(() => {+ interpolateColors(1, [1, 2, 3], ['#ffffff', '#aaaaaa']);+ }, /inputRange \(3\) and outputRange \(2\) must have the same length/);+});++test('Basic interpolate Colors', () => {+ expect(interpolateColors(1, [0, 1], ['#ffaadd', '#fabfdf'])).toBe(+ 'rgba(250, 191, 223, 1)'+ );});