mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-09 20:07:39 +00:00
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:
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user