import { describe, expect, it } from "vitest";
import { unwrapTemplate } from "./htmlTemplate.js";
describe("unwrapTemplate", () => {
it("returns the input unchanged when there is no template wrapper", () => {
const html = `
hello
`;
expect(unwrapTemplate(html)).toBe(html);
});
it("unwraps a bare top-level template fragment", () => {
const inner = `hi`;
const html = `${inner}`;
expect(unwrapTemplate(html)).toBe(inner);
});
it("unwraps a full document whose body only contains a template", () => {
const inner = ``;
const html = `${inner}`;
expect(unwrapTemplate(html)).toBe(inner);
});
it("returns the input unchanged when the closing template tag is missing", () => {
const html = `broken`;
expect(unwrapTemplate(html)).toBe(html);
});
it("returns an empty string for an empty template", () => {
const html = ``;
expect(unwrapTemplate(html)).toBe("");
});
it("preserves nested templates inside the outer wrapper", () => {
const inner = `outer-beforeinner-contentouter-after`;
const html = `${inner}`;
expect(unwrapTemplate(html)).toBe(inner);
});
it("leaves multiple sibling templates unchanged", () => {
const html = `amiddleb`;
expect(unwrapTemplate(html)).toBe(html);
});
});