hotfix: sample component test to work with react-testing-library

This commit is contained in:
George Lima 2018-11-28 17:03:31 -03:00
parent 4cdc1a94af
commit ae6e44f613
3 changed files with 36 additions and 75 deletions

View File

@ -1,16 +1,20 @@
import React from 'react';
import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import { render } from 'react-testing-library';
import { MemoryRouter } from 'react-router-dom';
import 'jest-dom/extend-expect';
import { SidebarComponent } from '../../app/components/sidebar/index';
describe('<Sidebar />', () => {
describe('render()', () => {
test('should render correctly', () => {
const wrapper = shallow(<SidebarComponent />);
const component = wrapper.dive();
const { asFragment } = render(
<MemoryRouter>
<SidebarComponent />
</MemoryRouter>,
);
expect(toJson(component)).toMatchSnapshot();
expect(asFragment()).toMatchSnapshot();
});
});
});

View File

@ -1,69 +1,30 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Sidebar /> render() should render correctly 1`] = `
<StyledComponent
forwardedClass={
Object {
"$$typeof": Symbol(react.forward_ref),
"attrs": Array [],
"componentStyle": ComponentStyle {
"componentId": "sc-bdVaJa",
"isStatic": true,
"rules": Array [
"
",
"
display: flex;
flex-direction: column;
width: 200px;
position: absolute;
left: 0;
top: 0;
height: 100vh;
background: #ccc;
",
"
",
],
},
"displayName": "styled.div",
"render": [Function],
"styledComponentId": "sc-bdVaJa",
"target": "div",
"toString": [Function],
"warnTooManyClasses": [Function],
"withComponent": [Function],
}
}
forwardedRef={null}
>
<Link
key="/"
replace={false}
to="/"
<DocumentFragment>
<div
class="sc-bdVaJa fnXMXv"
>
Dashboard
</Link>
<Link
key="/send"
replace={false}
to="/send"
>
Send
</Link>
<Link
key="/receive"
replace={false}
to="/receive"
>
Receive
</Link>
<Link
key="/settings"
replace={false}
to="/settings"
>
Settings
</Link>
</StyledComponent>
<a
href="/"
>
Dashboard
</a>
<a
href="/send"
>
Send
</a>
<a
href="/receive"
>
Receive
</a>
<a
href="/settings"
>
Settings
</a>
</div>
</DocumentFragment>
`;

View File

@ -1,6 +1,2 @@
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
jest.DEFAULT_TIMEOUT_INTERVAL = 10000;
Enzyme.configure({ adapter: new Adapter() });
jest.DEFAULT_TIMEOUT_INTERVAL = 20000;
jest.setTimeout(20000);