test.beforeEach(t => { let root = document.getElementById('root'); if (!root) { root = document.createElement('div'); root.id = 'root'; document.body.appendChild(root); } t.context.root = root; });
test('render div with children', t => { const root = t.context.root; const element = ( <div> <b /> <a href="foo" /> </div> ); render(element, root); t.is(root.innerHTML, '<div><b></b><a href="foo"></a></div>'); });
test('replace div to span', t => { const root = t.context.root; let element = <div>Foo</div>; render(element, root); t.is(root.innerHTML, '<div>Foo</div>'); const prevChild = root.firstElementChild; element = <span>Foo</span>; render(element, root); t.is(root.innerHTML, '<span>Foo</span>'); const nextChild = root.firstElementChild; t.not(prevChild, nextChild); });
test('render div with props', t => { const root = t.context.root; const element = { type: 'div', props: { id: 'foo' } }; render(element, root); t.is(root.innerHTML, '<div id="foo"></div>'); });
test('render jsx div', t => { const root = t.context.root; const element = <div>Foo</div>; render(element, root); t.is(root.innerHTML, '<div>Foo</div>'); render(element, root); t.is(root.innerHTML, '<div>Foo</div>'); });
test('render span with text child', t => { const root = t.context.root; const element = <span>Foo</span>; render(element, root); t.is(root.innerHTML, '<span>Foo</span>'); });
test('reuse div', t => { const root = t.context.root; let element = <div>Foo</div>; render(element, root); t.is(root.innerHTML, '<div>Foo</div>'); const prevChild = root.firstElementChild; element = <div>Bar</div>; render(element, root); t.is(root.innerHTML, '<div>Bar</div>'); const nextChild = root.firstElementChild; t.is(prevChild, nextChild); });
test('render div with props', t => { const root = t.context.root; const element = <div id="foo" />; render(element, root); t.is(root.innerHTML, '<div id="foo"></div>'); });
test.beforeEach(t => { let root = document.getElementById('root'); if (!root) { root = document.createElement('div'); root.id = 'root'; document.body.appendChild(root); } t.context.root = root; });
test.beforeEach(t => { let root = document.getElementById('root'); if (!root) { root = document.createElement('div'); root.id = 'root'; document.body.appendChild(root); } t.context.root = root; });
test.beforeEach(t => { let root = document.getElementById('root'); if (!root) { root = document.createElement('div'); root.id = 'root'; document.body.appendChild(root); } t.context.root = root; });
test.beforeEach(t => { let root = document.getElementById('root'); if (!root) { root = document.createElement('div'); root.id = 'root'; document.body.appendChild(root); } t.context.root = root; });
test('render jsx div', t => { const root = t.context.root; const element = <div />; render(element, root); t.is(root.innerHTML, '<div></div>'); });
test('render div', t => { const root = t.context.root; const element = { type: 'div', props: {} }; render(element, root); t.is(root.innerHTML, '<div></div>'); });
test.beforeEach(t => { let root = document.getElementById('root'); if (!root) { root = document.createElement('div'); root.id = 'root'; document.body.appendChild(root); } t.context.root = root; });