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
Tim Neutkens 9c4eefcdbf
Add prettier for examples directory (#5909)
* Add prettier for examples directory

* Fix files

* Fix linting

* Add prettier script in case it has to be ran again
2018-12-17 17:34:32 +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()
})
})