Skip to content

Instantly share code, notes, and snippets.

@pmkhoa
Created November 6, 2017 19:47
Show Gist options
  • Save pmkhoa/b7c85cd68f3b64fd5e65b200cf35bf9a to your computer and use it in GitHub Desktop.
Save pmkhoa/b7c85cd68f3b64fd5e65b200cf35bf9a to your computer and use it in GitHub Desktop.
describe('<Fragments Rendering/>', () => {
test('React 16 - fragments render', () => {
const Fragments = () => [
<li key="1">First item</li>,
<li key="2">Second item</li>,
<li key="3">Third item</li>,
]
const wrapper = shallow(<Fragments />)
expect(wrapper).toMatchSnapshot()
})
test('React 16 - normal render', () => {
const Fragments = () => (
<ul>
<li key="1">First item</li>
<li key="2">Second item</li>
<li key="3">Third item</li>
</ul>
)
const wrapper = shallow(<Fragments />)
expect(wrapper).toMatchSnapshot()
})
})
// Result
exports[`<Fragments Rendering/> React 16 - fragments render 1`] = `
Array [
<li
key="1"
/>,
<li
key="2"
/>,
<li
key="3"
/>,
]
`;
exports[`<Fragments Rendering/> React 16 - normal render 1`] = `
<ul>
<li
key="1"
>
First item
</li>
<li
key="2"
>
Second item
</li>
<li
key="3"
>
Third item
</li>
</ul>
`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment