mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-07 18:26:17 +00:00
fix(cli): bundle preview font localization (#2449)
This commit is contained in:
@@ -1,9 +1,19 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const producerMocks = vi.hoisted(() => ({
|
||||
loadProducer: vi.fn(async () => ({
|
||||
injectDeterministicFontFaces: async (html: string) => `${html}<!--bundled-producer-->`,
|
||||
})),
|
||||
}));
|
||||
|
||||
vi.mock("@hyperframes/core/compiler", () => ({
|
||||
bundleToSingleHtml: vi.fn(async () => "<html><body>bundled</body></html>"),
|
||||
}));
|
||||
|
||||
vi.mock("./producer.js", () => ({
|
||||
loadProducer: producerMocks.loadProducer,
|
||||
}));
|
||||
|
||||
import {
|
||||
__resetFontLocalizationWarningsForTests,
|
||||
bundleWithLocalizedFonts,
|
||||
@@ -31,6 +41,12 @@ describe("bundleWithLocalizedFonts (call-site integration)", () => {
|
||||
});
|
||||
|
||||
describe("localizeWithProducer", () => {
|
||||
it("loads the injector through the producer module bundled with the CLI", async () => {
|
||||
const out = await localizeWithProducer("<html></html>");
|
||||
expect(producerMocks.loadProducer).toHaveBeenCalledOnce();
|
||||
expect(out).toBe("<html></html><!--bundled-producer-->");
|
||||
});
|
||||
|
||||
it("embeds fonts when the injector is available", async () => {
|
||||
const inject = vi.fn(async (html: string) => `${html}<!--fonts-->`);
|
||||
const warn = vi.fn();
|
||||
|
||||
Reference in New Issue
Block a user