hotfix: sample component test to work with react-testing-library
This commit is contained in:
parent
4cdc1a94af
commit
ae6e44f613
|
@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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}
|
||||
<DocumentFragment>
|
||||
<div
|
||||
class="sc-bdVaJa fnXMXv"
|
||||
>
|
||||
<Link
|
||||
key="/"
|
||||
replace={false}
|
||||
to="/"
|
||||
<a
|
||||
href="/"
|
||||
>
|
||||
Dashboard
|
||||
</Link>
|
||||
<Link
|
||||
key="/send"
|
||||
replace={false}
|
||||
to="/send"
|
||||
</a>
|
||||
<a
|
||||
href="/send"
|
||||
>
|
||||
Send
|
||||
</Link>
|
||||
<Link
|
||||
key="/receive"
|
||||
replace={false}
|
||||
to="/receive"
|
||||
</a>
|
||||
<a
|
||||
href="/receive"
|
||||
>
|
||||
Receive
|
||||
</Link>
|
||||
<Link
|
||||
key="/settings"
|
||||
replace={false}
|
||||
to="/settings"
|
||||
</a>
|
||||
<a
|
||||
href="/settings"
|
||||
>
|
||||
Settings
|
||||
</Link>
|
||||
</StyledComponent>
|
||||
</a>
|
||||
</div>
|
||||
</DocumentFragment>
|
||||
`;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue