Skip to content

Commit bd9a092

Browse files
committed
Create inverse-lerp.test.ts
1 parent b747e6e commit bd9a092

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)