* Use vitest for some EW unit tests * Ensure library builds are done before unit tests * Stabilise jest tests * Move more tests over * Make sonar happier * Update types/node for happy-dom compat again * Decrease max-workers to stabilise jest tests * Split jest over 3 runners to alleviate memory woes * Switch jest to runInBand * Attempt to deflake jest tests * tweak coverage * tweak coverage
30 lines
830 B
TypeScript
30 lines
830 B
TypeScript
/*
|
|
Copyright 2024 New Vector Ltd.
|
|
Copyright 2021 Šimon Brandner <simon.bra.ag@gmail.com>
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
|
Please see LICENSE files in the repository root for full details.
|
|
*/
|
|
|
|
import { describe, it, expect } from "vitest";
|
|
|
|
import { lerp } from "./AnimationUtils";
|
|
|
|
describe("lerp", () => {
|
|
it("correctly interpolates", () => {
|
|
expect(lerp(0, 100, 0.5)).toBe(50);
|
|
expect(lerp(50, 100, 0.5)).toBe(75);
|
|
expect(lerp(0, 1, 0.1)).toBe(0.1);
|
|
});
|
|
|
|
it("clamps the interpolant", () => {
|
|
expect(lerp(0, 100, 50)).toBe(100);
|
|
expect(lerp(0, 100, -50)).toBe(0);
|
|
});
|
|
|
|
it("handles negative numbers", () => {
|
|
expect(lerp(-100, 0, 0.5)).toBe(-50);
|
|
expect(lerp(100, -100, 0.5)).toBe(0);
|
|
});
|
|
});
|