refactor(studio): double-cast test fixtures and split three dense functions

CONTRIBUTING.md allows `as unknown as T` with a justification, not a bare
`as T`; the gsapShared fixtures only carry the fields under test.

The fallow complexity gate flagged three functions on this branch. Each is
split at its natural seam rather than suppressed: the auto-expand scan moves
out of the effect, the four repeated attribute guards in
nodeMatchesManifestClip collapse into one table-driven check, and the
segment-% interpolation moves out of onPathDown.
This commit is contained in:
Miguel Angel Simon Sierra
2026-07-28 00:40:46 +02:00
parent b8ff8bf0f3
commit e317f1fbe3
4 changed files with 55 additions and 34 deletions
+7 -5
View File
@@ -11,17 +11,19 @@ import {
toClipPercentage,
} from "./gsapShared";
// Fixtures carry only the fields the function under test reads; the double-cast
// is the documented way to stand in for the full runtime shape (CONTRIBUTING.md).
const tween = (duration: number | undefined) => ({ duration }) as unknown as GsapAnimation;
describe("resolveEditableTweenDuration", () => {
const selection = { dataAttributes: { duration: "16.26" } } as DomEditSelection;
const selection = { dataAttributes: { duration: "16.26" } } as unknown as DomEditSelection;
it("uses the owning clip duration when the tween omits an outer duration", () => {
expect(resolveEditableTweenDuration({ duration: undefined } as GsapAnimation, selection)).toBe(
16.26,
);
expect(resolveEditableTweenDuration(tween(undefined), selection)).toBe(16.26);
});
it("keeps an explicitly-authored tween duration", () => {
expect(resolveEditableTweenDuration({ duration: 4 } as GsapAnimation, selection)).toBe(4);
expect(resolveEditableTweenDuration(tween(4), selection)).toBe(4);
});
});