Spaces:
Sleeping
Sleeping
| import { describe, expect, it } from "vitest"; | |
| import { project, rubberband, velocityFromSamples } from "./gestures"; | |
| describe("gestures", () => { | |
| it("projects velocity with Apple deceleration", () => { | |
| const distance = project(1000, 0.998); | |
| expect(distance).toBeCloseTo(499, 0); | |
| }); | |
| it("rubberbands overshoot toward zero", () => { | |
| const pulled = rubberband(100, 300, 0.55); | |
| expect(pulled).toBeGreaterThan(0); | |
| expect(pulled).toBeLessThan(100); | |
| }); | |
| it("computes velocity from pointer samples", () => { | |
| const v = velocityFromSamples( | |
| [ | |
| { t: 0, x: 0, y: 0 }, | |
| { t: 100, x: 0, y: 50 }, | |
| ], | |
| "y", | |
| ); | |
| expect(v).toBe(500); | |
| }); | |
| }); | |