mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-05 00:56:23 +00:00
* feat: make creator media edits render-safe * fix: align media playback timing * docs: add creator editing recipes * docs: expand creator editing guidance * fix: unify media source offsets * fix: scale natural media duration * fix: preserve natural media zero spans * fix: align compiled natural media timing * test: classify compiler media test as integration * fix: drop inactive media windows * fix: unify literal timing parsing * fix: keep browser media parsing serializable * fix: keep page timing readers strict * fix: close remaining preview timing gaps * fix(core): preserve Studio voice pitch at playback speed * chore: keep creator contract source-neutral
32 lines
998 B
TypeScript
32 lines
998 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { resolveNaturalMediaTimelineDuration } from "./playbackRate";
|
|
|
|
function elementWith(attributes: Record<string, string>): Pick<Element, "getAttribute"> {
|
|
return {
|
|
getAttribute(name) {
|
|
return attributes[name] ?? null;
|
|
},
|
|
};
|
|
}
|
|
|
|
describe("resolveNaturalMediaTimelineDuration", () => {
|
|
it.each([
|
|
["2x", 5],
|
|
["0x2", 10],
|
|
])("matches native playback-rate parsing for %s", (rate, expected) => {
|
|
expect(
|
|
resolveNaturalMediaTimelineDuration(elementWith({ "data-playback-rate": rate }), 10),
|
|
).toBe(expected);
|
|
});
|
|
|
|
it.each([10, 11])("returns a known zero span at or past source EOF (start=%s)", (start) => {
|
|
expect(
|
|
resolveNaturalMediaTimelineDuration(elementWith({ "data-media-start": String(start) }), 10),
|
|
).toBe(0);
|
|
});
|
|
|
|
it("returns null only when source duration is unknown", () => {
|
|
expect(resolveNaturalMediaTimelineDuration(elementWith({}), Number.NaN)).toBeNull();
|
|
});
|
|
});
|