Skip to content

🎥 Make videos programmatically with React

fix test smells

Jonas Brunner2d3207c5382f
diff --git a/packages/core/src/test/easing.test.ts b/packages/core/src/test/easing.test.ts
index 9a81a18e0d..af829e27e3 100644
--- a/packages/core/src/test/easing.test.ts
+++ b/packages/core/src/test/easing.test.ts
@@ -2,18 +2,24 @@ import {Easing} from '../easing';
const numbersToTest = [0, 0.4, 0.5, 0.7, 1];
-test('Easing linear', () => {
- const easingIn = Easing.in(Easing.linear);
- numbersToTest.forEach((n) => expect(easingIn(n)).toBe(n));
+describe('Easing linear', () => {
+ test('Easing In', () => {
+ const easingIn = Easing.in(Easing.linear);
+ numbersToTest.forEach((n) => expect(easingIn(n)).toBe(n));
+ });
- const easingOut = Easing.out(Easing.linear);
- numbersToTest.forEach((n) => expect(easingOut(n)).toBe(n));
+ test('Easing In Out', () => {
+ const easingOut = Easing.out(Easing.linear);
+ numbersToTest.forEach((n) => expect(easingOut(n)).toBe(n));
+ });
- const easingInOut = Easing.inOut(Easing.linear);
- numbersToTest.forEach((n) => expect(easingInOut(n)).toBe(n));
+ test('Easing Out', () => {
+ const easingInOut = Easing.inOut(Easing.linear);
+ numbersToTest.forEach((n) => expect(easingInOut(n)).toBe(n));
+ });
});
-test('Easing Quadratic', () => {
+describe('Easing Quadratic', () => {
const quad = (n: number) => n * n;
const out = (n: number) => 1 - quad(1 - n);
const inOut = (n: number) => {
@@ -22,17 +28,23 @@ test('Easing Quadratic', () => {
} else return quad(n * 2) / 2;
};
- const easingIn = Easing.in(Easing.quad);
- numbersToTest.forEach((n) => expect(easingIn(n)).toBe(quad(n)));
+ test('Easing In', () => {
+ const easingIn = Easing.in(Easing.quad);
+ numbersToTest.forEach((n) => expect(easingIn(n)).toBe(quad(n)));
+ });
- const easingOut = Easing.out(Easing.quad);
- numbersToTest.forEach((n) => expect(easingOut(n)).toBe(out(n)));
+ test('Easing In Out', () => {
+ const easingOut = Easing.out(Easing.quad);
+ numbersToTest.forEach((n) => expect(easingOut(n)).toBe(out(n)));
+ });
- const easingInOut = Easing.inOut(Easing.quad);
- numbersToTest.forEach((n) => expect(easingInOut(n)).toBe(inOut(n)));
+ test('Easing Out', () => {
+ const easingInOut = Easing.inOut(Easing.quad);
+ numbersToTest.forEach((n) => expect(easingInOut(n)).toBe(inOut(n)));
+ });
});
-test('Easing Cubic', () => {
+describe('Easing Cubic', () => {
const cubic = (n: number) => n * n * n;
const out = (n: number) => 1 - cubic(1 - n);
const inOut = (n: number) => {
@@ -41,12 +53,18 @@ test('Easing Cubic', () => {
} else return cubic(n * 2) / 2;
};
- const easingIn = Easing.in(Easing.cubic);
- numbersToTest.forEach((n) => expect(easingIn(n)).toBe(cubic(n)));
+ test('Easing In', () => {
+ const easingIn = Easing.in(Easing.cubic);
+ numbersToTest.forEach((n) => expect(easingIn(n)).toBe(cubic(n)));
+ });
- const easingOut = Easing.out(Easing.cubic);
- numbersToTest.forEach((n) => expect(easingOut(n)).toBe(out(n)));
+ test('Easing In Out', () => {
+ const easingOut = Easing.out(Easing.cubic);
+ numbersToTest.forEach((n) => expect(easingOut(n)).toBe(out(n)));
+ });
- const easingInOut = Easing.inOut(Easing.cubic);
- numbersToTest.forEach((n) => expect(easingInOut(n)).toBe(inOut(n)));
+ test('Easing Out', () => {
+ const easingInOut = Easing.inOut(Easing.cubic);
+ numbersToTest.forEach((n) => expect(easingInOut(n)).toBe(inOut(n)));
+ });
});
diff --git a/packages/core/src/test/quality.test.ts b/packages/core/src/test/quality.test.ts
index 2c8f73b991..942a37f8f9 100644
--- a/packages/core/src/test/quality.test.ts
+++ b/packages/core/src/test/quality.test.ts
@@ -1,41 +1,47 @@
import {getQuality, setQuality} from '../config/quality';
import {expectToThrow} from './expect-to-throw';
-test('set quality tests valid input', () => {
- // input quality
- const valuesA = [50, undefined, 100, 1];
- valuesA.forEach((entry) => {
- setQuality(entry);
- expect(getQuality()).toEqual(entry);
+describe('Test valid setQuality inputs', () => {
+ test('Integers within accepted range', () => {
+ const validInputes = [1, 50, 100];
+ validInputes.forEach((entry) => {
+ setQuality(entry);
+ expect(getQuality()).toEqual(entry);
+ });
});
- // input quality, output quality
- const valuesB = [[0, undefined]];
- valuesB.forEach((entry) => {
- setQuality(entry[0]);
- expect(getQuality()).toEqual(entry[1]);
+ test('Undefined input', () => {
+ setQuality(undefined);
+ expect(getQuality()).toEqual(undefined);
+ });
+
+ test('0 input', () => {
+ setQuality(0);
+ expect(getQuality()).toEqual(undefined);
});
});
-test('set quality tests invalid input', () => {
- // input quality
- const valuesC = ['abc', null];
- valuesC.forEach((entry) =>
- expectToThrow(
- // @ts-expect-error
- () => setQuality(entry),
- new RegExp(
- `Quality option must be a number or undefined. Got ${typeof entry}`
+describe('Test invalid setQuality inputs ', () => {
+ test('invalid input type', () => {
+ const invalidInputQuality = ['abc', null];
+ invalidInputQuality.forEach((entry) =>
+ expectToThrow(
+ // @ts-expect-error
+ () => setQuality(entry),
+ new RegExp(
+ `Quality option must be a number or undefined. Got ${typeof entry}`
+ )
)
- )
- );
+ );
+ });
- // input quality
- const valuesD = [-1, 101, 150];
- valuesD.forEach((entry) =>
- expectToThrow(
- () => setQuality(entry),
- /Quality option must be between 1 and 100./
- )
- );
+ test('out of range inputs', () => {
+ const outOfRangeInput = [-1, 101, 150];
+ outOfRangeInput.forEach((entry) =>
+ expectToThrow(
+ () => setQuality(entry),
+ /Quality option must be between 1 and 100./
+ )
+ );
+ });
});