Mount a Deku component to the DOM to facilitate testing.
Code is originally by Dominic Barnes.
npm install deku-component-mount
import assert from 'assert'
import mount from 'deku-component-mount'
import element from 'virtual-element'
import Mock from 'component-mock'
const Component = {
render: function () {
return element('div', {id: 'hello-world'}, 'Hello World!')
}
}
const node = Mock(Component).render()
const mountedNode = mount(node)
assert(document.getElementById('hello-world')) //=> passes
mountedNode.unmount()
assert(document.getElementById('hello-world')) //=> fails
Mount a Deku node to the DOM and return an object with a property element
containing a reference to the rendered DOM element and a property unmount
containing a function to remove the rendered DOM element from the DOM.
Remove the rendered element from the DOM
A reference to the mounted dom element
MIT