1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/examples/with-ioc/__tests__/blog.page_with_provide.test.js
Alex Indigo e401e2cf5f Added IoC example (#3595)
* Added `with-ioc` example

* pre-compile deps until we get nextjs magic working
2018-01-31 08:36:20 +01:00

36 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* eslint-env jest */
/*
* Testing pages with @provide decorator:
*
* Snapshots as usual
*
* Shallow rendering need to `.dive()` one level deep,
* as with any High Order Component.
* Also `.html()` may cause havoc when it'd try to expand the render
* but won't inject context since top level co,ponent has been rendered already.
* This problem is not unique to IoC though, anything that relies on context (i.e. Redux)
* is facing the same issue. Use `.debug()` or `mount()` instead
*/
import { shallow } from 'enzyme'
import React from 'react'
import renderer from 'react-test-renderer'
import App from '../pages/blog.js'
describe('With Enzyme', () => {
it('Blog renders components', () => {
const app = shallow(<App post={{title: 'Hi There!'}} />).dive()
expect(app.find('h1').text()).toEqual('Hi There!')
})
})
describe('With Snapshot Testing', () => {
it('Blog renders components', () => {
const component = renderer.create(<App post={{title: 'Hi There!'}} />)
const tree = component.toJSON()
expect(tree).toMatchSnapshot()
})
})