mirror of
https://github.com/hanzoai/frames.git
synced 2026-09-24 00:08:03 +00:00
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
import { isHtmlInCanvasCaptureSupported } from "./capture.js";
|
|
|
|
describe("isHtmlInCanvasCaptureSupported", () => {
|
|
afterEach(() => {
|
|
vi.unstubAllGlobals();
|
|
});
|
|
|
|
it("returns false outside the browser", () => {
|
|
vi.stubGlobal("document", undefined);
|
|
|
|
expect(isHtmlInCanvasCaptureSupported()).toBe(false);
|
|
});
|
|
|
|
it("returns true when layoutSubtree and drawElementImage are available", () => {
|
|
vi.stubGlobal("document", {
|
|
createElement: () => ({
|
|
setAttribute: () => undefined,
|
|
layoutSubtree: true,
|
|
getContext: () => ({
|
|
drawElementImage: () => undefined,
|
|
}),
|
|
}),
|
|
});
|
|
|
|
expect(isHtmlInCanvasCaptureSupported()).toBe(true);
|
|
});
|
|
|
|
it("returns false when drawElementImage is missing", () => {
|
|
vi.stubGlobal("document", {
|
|
createElement: () => ({
|
|
setAttribute: () => undefined,
|
|
layoutSubtree: true,
|
|
getContext: () => ({}),
|
|
}),
|
|
});
|
|
|
|
expect(isHtmlInCanvasCaptureSupported()).toBe(false);
|
|
});
|
|
});
|