fraserxu / spy-react-component-lifecycle

spy-react-component-lifecycle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

spy-react-component-lifecycle

Build Status

A separate module for spy react component lifecycle, code from enzyme which is deprecated at v2.0.0

Install

$ npm install spy-react-component-lifecycle --save-dev

Usage

Go and check test.js.

var Foo = React.createClass({
  componentDidMount: noop,
  render: function render () {
    return React.createElement('div', null, 'foo')
  }
})

test('Componenet life cycle', function (assert) {
  withDom()

  spyLifeCycle(Foo)
  var container = window.document.createElement('div')
  ReactDOM.render(React.createElement(Foo), container)

  assert.true(Foo.prototype.componentDidMount.calledOnce, 'calls componentDidMount once')

  assert.end()
})

Notes: Sincejsdom 7.x onward only works on Node.js 4 or newer, the test may only work for Node.js 4 or newer.

License

MIT

About

spy-react-component-lifecycle

License:MIT License


Languages

Language:JavaScript 100.0%