We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b747e6e commit bd9a092Copy full SHA for bd9a092
src/packages/core/utils/math/inverse-lerp.test.ts
@@ -0,0 +1,16 @@
1
+import { expect } from '@open-wc/testing';
2
+import { inverseLerp, lerp } from './math.js';
3
+
4
+describe('inverse lerp', () => {
5
+ it('Calculate the inverse lerp factor for a value between two points.', () => {
6
+ expect(inverseLerp(10, 20, 15)).to.equal(0.5);
7
+ expect(inverseLerp(10, 20, 10)).to.equal(0);
8
+ expect(inverseLerp(10, 20, 20)).to.equal(1);
9
+ expect(inverseLerp(10, 20, 5)).to.equal(-0.5);
10
+ expect(inverseLerp(10, 20, 25)).to.equal(1.5);
11
+ });
12
13
+ it('Handle the case where start and end are equal.', () => {
14
+ expect(inverseLerp(5, 5, 5)).to.equal(0);
15
16
+});
0 commit comments