Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test(`{ mapRange(0, 2, (i) => <div></div>) }`, () => {
const v1 = h.div().k("a");
const v2 = h.div().k("b");
const v = h.div().c(mapRange(0, 2, i => i === 0 ? v1 : v2));
expect(v._c).toBe(v1);
expect(v1._f & VNodeFlags.Key).toBeTruthy();
expect(v1._k).toBe("a");
expect(v2._f & VNodeFlags.Key).toBeTruthy();
expect(v2._k).toBe("b");
expect(v1._l).toBe(v2);
expect(v1._r).toBe(v2);
expect(v2._l).toBe(v1);
expect(v2._r).toBeNull();
});
test(`<div></div>`, () => {
const v1 = h.div();
const v = h.div().c(v1);
expect(v._c).toBe(v1);
expect(v1._f & VNodeFlags.Key).toBeFalsy();
expect(v1._k).toBe(0);
expect(v1._l).toBe(v1);
expect(v1._r).toBeNull();
});
test(`<div></div><div></div>`, () => {
const v1 = h.div();
const v2 = h.div();
const v = h.div().c(v1, v2);
expect(v._c).toBe(v1);
expect(v1._f & VNodeFlags.Key).toBeFalsy();
expect(v1._k).toBe(0);
expect(v2._f & VNodeFlags.Key).toBeFalsy();
expect(v2._k).toBe(1);
expect(v1._l).toBe(v2);
expect(v1._r).toBe(v2);
expect(v2._l).toBe(v1);
expect(v2._r).toBeNull();
});
test(`{ children(<div></div><div></div>) }`, () => {
const v1 = h.div();
const v2 = h.div();
const v = h.div().c(fragment(v1, v2));
expect(v._c).toBe(v1);
expect(v1._f & VNodeFlags.Key).toBeFalsy();
expect(v1._k).toBe(0);
expect(v2._f & VNodeFlags.Key).toBeFalsy();
expect(v2._k).toBe(1);
expect(v1._l).toBe(v2);
expect(v1._r).toBe(v2);
expect(v2._l).toBe(v1);
expect(v2._r).toBeNull();
});
test(`{ children(<div></div><div></div>) }`, () => {
const v1 = h.div();
const v2 = h.div();
const v = h.div().c(fragment(v1, v2));
expect(v._c).toBe(v1);
expect(v1._f & VNodeFlags.Key).toBeFalsy();
expect(v1._k).toBe(0);
expect(v2._f & VNodeFlags.Key).toBeFalsy();
expect(v2._k).toBe(1);
expect(v1._l).toBe(v2);
expect(v1._r).toBe(v2);
expect(v2._l).toBe(v1);
expect(v2._r).toBeNull();
});
test(`<div></div>`, () => {
const v1 = h.div();
const first = fragment(v1);
expect(first).toBe(v1);
expect(v1._l).toBe(v1);
expect(v1._r).toBeNull();
});
test("<div class="a">", () => {
expect(render(h.div("a")).toSnapshot()).toMatchSnapshot();
});
</div>
test("<div class="a b">", () => {
expect(render(h.div("a b")).toSnapshot()).toMatchSnapshot();
});
</div>
render() {
if (this.state === 1) {
return h.span().c(1);
}
return h.div().c(0);
}
expect(() => h.div("", { unsafeHTML: UNSAFE_HTML("<span></span>") }).c("abc")).toThrow(Error);
});