fixup! [IMP] svg namespace support

This commit is contained in:
Bruno Boi
2021-11-19 12:42:11 +01:00
committed by Géry Debongnie
parent ea74739d46
commit 345c44b952
2 changed files with 40 additions and 2 deletions
+12 -2
View File
@@ -1,8 +1,9 @@
import { renderToString, snapshotEverything } from "../helpers";
// NB: check the snapshots to see where the SVG namespaces are added
snapshotEverything();
describe.only("properly support svg", () => {
describe("properly support svg", () => {
test("add proper namespace to svg", () => {
const template = `<svg width="100px" height="90px"><circle cx="50" cy="50" r="4" stroke="green" stroke-width="1" fill="yellow"/> </svg>`;
expect(renderToString(template)).toBe(
@@ -11,10 +12,19 @@ describe.only("properly support svg", () => {
});
test("add proper namespace to g tags", () => {
// this is necessary if one wants to use components in a svg
const template = `<g><circle cx="50" cy="50" r="4" stroke="green" stroke-width="1" fill="yellow"/> </g>`;
expect(renderToString(template)).toBe(
`<g><circle cx=\"50\" cy=\"50\" r=\"4\" stroke=\"green\" stroke-width=\"1\" fill=\"yellow\"></circle> </g>`
);
});
test("namespace to g tags not added if already in svg namespace", () => {
const template = `<svg><g/></svg>`;
expect(renderToString(template)).toBe(`<svg><g></g></svg>`);
});
test("namespace to svg tags added even if already in svg namespace", () => {
const template = `<svg><svg/></svg>`;
expect(renderToString(template)).toBe(`<svg><svg></svg></svg>`);
});
});