Home

Awesome

deku-component-is-node Build Status

Determine if an object is a valid Deku node. Useful for testing.

Example

import isNode from 'deku-component-is-node'
import element from 'virtual-element'
import Mock from 'component-mock'

const Component = {
  render: function () {
    element('div', [
      element('span', 'Hello World!')
    ])
  }
}

const mock = Mock(component)
const node = mock.render()

isNode(node) //=> returns `true`
isNode(node, 'div') //=> returns `true`
isNode(node, 'span') //=> returns `false`

API

isNode(node, [type])

Returns true if node is a valid Deku node. If type is specified, it will ensure that type is strictly equal. (whether that is a Component or a String element name)

License

MIT