diff options
| author | Maze Winther <mazewinther@gmail.com> | 2026-04-14 18:34:33 +0200 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2026-04-14 18:34:33 +0200 |
| commit | 8a54e5d88473d8b2b5a29fb20dbc70422d6018f5 (patch) | |
| tree | f0207ed115c40c9cd9521edc84b2ebfbe666a98b /apps/web/src/lib/animation/__tests__ | |
| parent | 5e6c26f3c1c4aa2c816049a492bc73a5f2e98ade (diff) | |
| download | opencut-8a54e5d88473d8b2b5a29fb20dbc70422d6018f5.tar.gz | |
test: remove keyframe query
Diffstat (limited to 'apps/web/src/lib/animation/__tests__')
| -rw-r--r-- | apps/web/src/lib/animation/__tests__/keyframe-query.test.ts | 139 |
1 files changed, 0 insertions, 139 deletions
diff --git a/apps/web/src/lib/animation/__tests__/keyframe-query.test.ts b/apps/web/src/lib/animation/__tests__/keyframe-query.test.ts deleted file mode 100644 index 319493c8..00000000 --- a/apps/web/src/lib/animation/__tests__/keyframe-query.test.ts +++ /dev/null @@ -1,139 +0,0 @@ -import { describe, expect, test } from "bun:test"; -import { - getElementKeyframes, - getKeyframeById, - getKeyframeAtTime, -} from "@/lib/animation/keyframe-query"; -import type { - ElementAnimations, - ScalarAnimationKey, -} from "@/lib/animation/types"; - -function createScalarKey({ - id, - time, - value, -}: { - id: string; - time: number; - value: number; -}): ScalarAnimationKey { - return { - id, - time, - value, - segmentToNext: "linear", - tangentMode: "flat", - }; -} - -function buildPositionAnimations({ - xKeys, - yKeys, -}: { - xKeys: ScalarAnimationKey[]; - yKeys: ScalarAnimationKey[]; -}): ElementAnimations { - return { - bindings: { - "transform.position": { - path: "transform.position", - kind: "vector2", - components: [ - { key: "x", channelId: "transform.position:x" }, - { key: "y", channelId: "transform.position:y" }, - ], - }, - }, - channels: { - "transform.position:x": { - kind: "scalar", - keys: xKeys, - }, - "transform.position:y": { - kind: "scalar", - keys: yKeys, - }, - }, - }; -} - -describe("keyframe query", () => { - test("returns keyframes from any component channel", () => { - const animations = buildPositionAnimations({ - xKeys: [createScalarKey({ id: "x-1", time: 1, value: 10 })], - yKeys: [createScalarKey({ id: "y-2", time: 2, value: 20 })], - }); - - expect( - getElementKeyframes({ animations }).map(({ id, time }) => ({ - id, - time, - })), - ).toEqual([ - { id: "x-1", time: 1 }, - { id: "y-2", time: 2 }, - ]); - }); - - test("finds a keyframe at time on a non-primary component", () => { - const animations = buildPositionAnimations({ - xKeys: [createScalarKey({ id: "x-1", time: 1, value: 10 })], - yKeys: [createScalarKey({ id: "y-2", time: 2, value: 20 })], - }); - - expect( - getKeyframeAtTime({ - animations, - propertyPath: "transform.position", - time: 2, - }), - ).toMatchObject({ - id: "y-2", - time: 2, - }); - }); - - test("finds a keyframe by id on a non-primary component", () => { - const animations = buildPositionAnimations({ - xKeys: [createScalarKey({ id: "x-1", time: 1, value: 10 })], - yKeys: [createScalarKey({ id: "y-2", time: 2, value: 20 })], - }); - - expect( - getKeyframeById({ - animations, - propertyPath: "transform.position", - keyframeId: "y-2", - }), - ).toMatchObject({ - id: "y-2", - time: 2, - value: { x: 10, y: 20 }, - }); - }); - - test("prefers the primary component when multiple components share a time", () => { - const animations = buildPositionAnimations({ - xKeys: [createScalarKey({ id: "x-1", time: 1, value: 10 })], - yKeys: [createScalarKey({ id: "y-1", time: 1, value: 20 })], - }); - - expect( - getElementKeyframes({ animations }).map(({ id, time }) => ({ - id, - time, - })), - ).toEqual([{ id: "x-1", time: 1 }]); - expect( - getKeyframeAtTime({ - animations, - propertyPath: "transform.position", - time: 1, - }), - ).toMatchObject({ - id: "x-1", - time: 1, - }); - }); -}); |
