Skip to content

Commit a8f77dc

Browse files
committed
add tests for provided interpolators
1 parent 4498648 commit a8f77dc

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.test.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Layer } from 'expression-globals-typescript';
2-
import { animate } from './index';
2+
import { animate, interpolators } from './index';
33

44
// This let's Jest: ReferenceError: Cannot access before initialization
55
// https://stackoverflow.com/questions/61157392/jest-mock-aws-sdk-referenceerror-cannot-access-before-initialization
@@ -80,6 +80,42 @@ test('animates with custom linear interpolator', () => {
8080
).toBe(0.5);
8181
});
8282

83+
test('animates with provided linear interpolator', () => {
84+
expect(
85+
animate(
86+
[
87+
{ keyTime: 0, keyValue: 0 },
88+
{ keyTime: 1, keyValue: 1 },
89+
],
90+
{ inputTime: 0.5, interpolator: interpolators.linear }
91+
)
92+
).toBe(0.5);
93+
});
94+
95+
test('animates with provided easeInOutQuad interpolator', () => {
96+
expect(
97+
animate(
98+
[
99+
{ keyTime: 0, keyValue: 0 },
100+
{ keyTime: 1, keyValue: 1 },
101+
],
102+
{ inputTime: 0.25, interpolator: interpolators.easeInOutQuad }
103+
)
104+
).toBe(0.125);
105+
});
106+
107+
test('animates with provided elastic interpolator', () => {
108+
expect(
109+
animate(
110+
[
111+
{ keyTime: 0, keyValue: 0 },
112+
{ keyTime: 2, keyValue: 1 },
113+
],
114+
{ inputTime: 2, interpolator: interpolators.easeInElastic }
115+
)
116+
).toBe(1);
117+
});
118+
83119
test('animates with custom quad interpolator', () => {
84120
expect(
85121
animate(

0 commit comments

Comments
 (0)