Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('Should create new object when dom exists', () => {
const bar = createVNode(VNodeFlags.HtmlElement, 'div', null, createTextVNode('123'), ChildFlags.HasVNodeChildren);
const foo = createVNode(VNodeFlags.HtmlElement, 'div', null, bar, ChildFlags.HasVNodeChildren);
render(foo, container);
expect(container.innerHTML).toEqual('<div><div>123</div></div>');
render(null, container);
render(foo, container);
expect(container.innerHTML).toEqual('<div><div>123</div></div>');
});
it('Should do nothing if lastVNode strictly equals nextVnode', () => {
const yar = createVNode(VNodeFlags.HtmlElement, 'div', null, createTextVNode('123'), ChildFlags.HasVNodeChildren, null, null, null);
const bar = createVNode(VNodeFlags.HtmlElement, 'div', null, createTextVNode('123'), ChildFlags.HasVNodeChildren, null, null, null);
let foo = createVNode(VNodeFlags.HtmlElement, 'div', null, [bar, yar], ChildFlags.HasNonKeyedChildren, null, null, null);
render(foo, container);
expect(container.innerHTML).toEqual('<div><div>123</div><div>123</div></div>');
foo = createVNode(VNodeFlags.HtmlElement, 'div', null, [bar, yar], ChildFlags.HasNonKeyedChildren, null, null, null);
render(foo, container);
expect(container.innerHTML).toEqual('<div><div>123</div><div>123</div></div>');
});
it('Should throw error when trying to render to document.body', () => {
const div = createVNode(VNodeFlags.HtmlElement, 'div', null, createTextVNode('1'), ChildFlags.HasVNodeChildren);
try {
render(div, document.body);
} catch (e) {
expect(e.message).toEqual('Inferno Error: you cannot render() to the "document.body". Use an empty element as a container instead.');
}
});