a component renders inside a
warns, naming where the parser put it", () => {
const P = (props: { children: any }) =>
{props.children}
;
const Badge = () =>
x
;
container.innerHTML =
'
';
expect(container.querySelector("p")!.children.length).toBe(0);
dispose = hydrate(
() => (
),
container
);
flush();
const msgs = nesting();
expect(msgs).toHaveLength(1);
expect(msgs[0]).toContain("rendered
inside
");
expect(msgs[0]).toContain("it now sits in ");
});
test("an inside an warns", () => {
const A = (props: { children: any }) => {props.children};
const Inner = () => in;
container.innerHTML =
'';
dispose = hydrate(
() => (
),
container
);
flush();
expect(nesting()).toHaveLength(1);
expect(nesting()[0]).toContain("rendered inside ");
});
test("rows straight into a warn once, naming the implied ", () => {
const [rows] = createSignal(["a", "b"]);
container.innerHTML =
"";
expect(container.querySelector("table")!.firstElementChild!.localName).toBe("tbody");
dispose = hydrate(
() => (
),
container
);
flush();
const msgs = nesting();
expect(msgs).toHaveLength(1);
expect(msgs[0]).toContain("wrapped it in a it added");
});
test("a ;
const G = () => (
);
container.innerHTML =
'';
dispose = hydrate(
() => (
),
container
);
flush();
const miss = warn.mock.calls.map(c => String(c[0])).filter(m => m.includes("Hydration key miss"));
expect(miss).toHaveLength(1);
expect(miss[0]).toContain("forms cannot nest");
});
test("valid nesting and an explicit hydrate, update and warn nothing", () => {
const [rows, setRows] = createSignal(["a", "b"]);
const Wrap = (props: { children: any }) => {props.children}
;
container.innerHTML =
'';
dispose = hydrate(
() => (
),
container
);
flush();
setRows(r => [...r.slice(1), "z"]);
flush();
expect(container.querySelector("tbody")!.textContent).toBe("bz");
expect(nesting()).toEqual([]);
});