(undefined as any);
let syncCalls = 0;
let requestUpdates = 0;
(cell as any).sync = () => {
syncCalls++;
pushUpdate(cell, "loaded from sync");
return Promise.resolve("loaded from sync");
};
el.requestUpdate = (() => {
requestUpdates++;
}) as typeof el.requestUpdate;
el.content = cell;
(el as any).willUpdate(new Map([["content", "old content"]]));
await Promise.resolve();
expect(syncCalls).toBe(1);
expect((el as any)._getContentValue()).toBe("loaded from sync");
expect(requestUpdates).toBeGreaterThan(0);
});
});
describe("variant", () => {
it("should accept inverse variant", () => {
const el = new CFMarkdown();
el.variant = "inverse";
expect(el.variant).toBe("inverse");
});
});
describe("streaming", () => {
it("should accept streaming prop", () => {
const el = new CFMarkdown();
el.streaming = true;
expect(el.streaming).toBe(true);
});
});
describe("entity decoding", () => {
it("should decode basic HTML entities", () => {
const el = new CFMarkdown();
const decoded = (el as any)._decodeHtmlEntities("<div>&"");
expect(decoded).toBe('&"');
});
it("should decode numeric entities in fallback mode", () => {
const el = new CFMarkdown();
// Force fallback mode (test environment has no document)
const decoded = (el as any)._decodeHtmlEntities("<>");
expect(decoded).toBe("<>");
});
it("should decode hex entities in fallback mode", () => {
const el = new CFMarkdown();
const decoded = (el as any)._decodeHtmlEntities("<>");
expect(decoded).toBe("<>");
});
});
});