philomena/assets/js/utils/__tests__/lerp.spec.ts

18 lines
529 B
TypeScript
Raw Permalink Normal View History

2024-06-03 23:43:51 +02:00
import { lerp } from '../lerp';
describe('Linear interpolation', () => {
describe('lerp', () => {
it('should interpolate the min-max range based on a delta', () => {
expect(lerp(0.5, 0, 100)).toEqual(50);
expect(lerp(0.75, 0, 100)).toEqual(75);
});
2024-06-03 23:43:51 +02:00
it('should clamp the value between min and max', () => {
expect(lerp(-999, 0, 100)).toEqual(0);
expect(lerp(0, 0, 100)).toEqual(0);
expect(lerp(999, 0, 100)).toEqual(100);
expect(lerp(1, 0, 100)).toEqual(100);
});
});
});