import { renderToString, renderToBdom, snapshotEverything, makeTestFixture } from "../helpers";
import { mount } from "../../src/blockdom";
// NB: check the snapshots to see where the SVG namespaces are added
snapshotEverything();
describe("properly support svg", () => {
test("add proper namespace to svg", () => {
const template = ``;
expect(renderToString(template)).toBe(
``
);
});
test("add proper namespace to g tags", () => {
const template = ` `;
expect(renderToString(template)).toBe(
` `
);
});
test("namespace to g tags not added if already in svg namespace", () => {
const template = ``;
expect(renderToString(template)).toBe(``);
});
test("namespace to svg tags added even if already in svg namespace", () => {
const template = ``;
const bdom = renderToBdom(template);
const fixture = makeTestFixture();
mount(bdom, fixture);
const elems = fixture.querySelectorAll("svg");
expect(elems.length).toEqual(2);
for (const el of elems) {
expect(el.namespaceURI).toBe("http://www.w3.org/2000/svg");
}
});
test("svg namespace added to sub-blocks", () => {
const template = ``;
expect(renderToString(template, { path: false })).toBe(``);
expect(renderToString(template, { path: true })).toBe(``);
const bdom = renderToBdom(template, { path: true });
const fixture = makeTestFixture();
mount(bdom, fixture);
const elems = fixture.querySelectorAll("svg, path");
expect(elems.length).toEqual(2);
for (const el of elems) {
expect(el.namespaceURI).toBe("http://www.w3.org/2000/svg");
}
});
});