mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-04 13:07:11 +00:00
test(core): pin three composition-length rules that no test covered (#5000)
* test(core): pin the authored floor's direct children, the one-frame media skip and lottie sources * test(core): pin the loaded-Lottie-library half of the pending rule
This commit is contained in:
@@ -5,7 +5,10 @@ import {
|
||||
MIN_VALID_TIMELINE_DURATION_SECONDS,
|
||||
readStaticCompositionMeta,
|
||||
resolveCompositionLengthSeconds,
|
||||
resolveContentDerivedDuration,
|
||||
resolveMediaWindowDurationSeconds,
|
||||
} from "./compositionLength";
|
||||
import { createRuntimeStartTimeResolver } from "./startResolver";
|
||||
|
||||
describe("resolveCompositionLengthSeconds", () => {
|
||||
const base = {
|
||||
@@ -108,3 +111,55 @@ describe("findRootCompositionElement", () => {
|
||||
expect(findRootCompositionElement(doc)?.getAttribute("data-composition-id")).toBe("b");
|
||||
});
|
||||
});
|
||||
|
||||
describe("rules moved unchanged from the runtime", () => {
|
||||
const resolverFor = (doc: Document) =>
|
||||
createRuntimeStartTimeResolver({
|
||||
timelineRegistry: {},
|
||||
includeAuthoredTimingAttrs: true,
|
||||
documentRef: doc,
|
||||
});
|
||||
|
||||
it("counts only the root's own sub-compositions in the authored floor", () => {
|
||||
const html =
|
||||
`<div data-composition-id="main"><div data-composition-id="scene" data-start="1" data-duration="2">` +
|
||||
`<div data-composition-id="inner" data-start="0" data-duration="50"></div></div></div>`;
|
||||
expect(readStaticCompositionMeta(parseHTMLContent(html))?.durationSeconds).toBe(3);
|
||||
});
|
||||
|
||||
it("skips a media clip of one frame or less", () => {
|
||||
const doc = parseHTMLContent(
|
||||
`<div data-composition-id="main"><video data-start="5"></video></div>`,
|
||||
);
|
||||
const tooShort = MIN_VALID_TIMELINE_DURATION_SECONDS;
|
||||
expect(
|
||||
resolveMediaWindowDurationSeconds(doc, {
|
||||
mediaStart: () => 5,
|
||||
mediaDuration: () => tooShort,
|
||||
}),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("holds the derived length while a declared Lottie source has not registered", () => {
|
||||
const doc = parseHTMLContent(
|
||||
`<div data-composition-id="main"><div data-start="0" data-duration="3"></div>` +
|
||||
`<div data-lottie-src="anim.json"></div></div>`,
|
||||
);
|
||||
const root = findRootCompositionElement(doc)!;
|
||||
const result = resolveContentDerivedDuration(root, resolverFor(doc), {
|
||||
unregisteredLottie: false,
|
||||
});
|
||||
expect(result).toMatchObject({ seconds: null, source: "unresolved" });
|
||||
});
|
||||
|
||||
it("holds the derived length while a loaded Lottie library may still register animations", () => {
|
||||
const doc = parseHTMLContent(
|
||||
`<div data-composition-id="main"><div data-start="0" data-duration="3"></div></div>`,
|
||||
);
|
||||
const root = findRootCompositionElement(doc)!;
|
||||
const result = resolveContentDerivedDuration(root, resolverFor(doc), {
|
||||
unregisteredLottie: true,
|
||||
});
|
||||
expect(result).toMatchObject({ seconds: null, source: "unresolved" });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user