How to use the enzyme/mount function in enzyme

To help you get started, we’ve selected a few enzyme examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thomasthiebaud / react-kit / src / routes / Home / __tests__ / Home.spec.js View on Github external
it('should render a the Home component', () => {
    const spy = sinon.spy()
    expect(spy.called).toEqual(false)

    const wrapper = mount()

    expect(spy.called).toEqual(true)
    expect(wrapper.find('h1').text()).toEqual('Hello test')
  })
})
github thomasthiebaud / react-kit / src / routes / __tests__ / index.spec.js View on Github external
it('should render a router', () => {
    const wrapper = mount()
    expect(wrapper.find(BrowserRouter).length).toEqual(1)
  })
})
github thomasthiebaud / react-kit / src / routes / Home / __tests__ / Container.spec.js View on Github external
it('should get container', () => {
    state.injectReducer('home', reducer)
    state.injectSagas(sagas)

    const wrapper = mount(
      
        
      )

    const home = wrapper.find(Home)
    expect(home.prop('greetings')).toEqual('Everyone !!!')
  })
})
github thomasthiebaud / react-kit / src / components / AsyncRoute / __tests__ / LazilyLoad.spec.js View on Github external
it('should render the component once it is loaded', done => {
    const component = () =&gt; (<h1>Hello world</h1>)
    const spy = sinon.spy(() =&gt; Promise.resolve(component))

    const wrapper = mount(
      
        {Component =&gt; (
          
        )}
      
    )

    setTimeout(() =&gt; {
      try {
        expect(wrapper.find('h1').text()).toEqual('Hello world')
        done()
      } catch (e) {
        done.fail(e)
      }
github thomasthiebaud / react-kit / src / components / AsyncRoute / __tests__ / AsyncRoute.spec.js View on Github external
it('should render the component once it is loaded', () =&gt; {
    const wrapper = mount(
      
        
      
    )

    setTimeout(() =&gt; {
      expect(wrapper.contains(
        
          
        
      )).toEqual(true)
    }, 100)
  })
})