scrollbar: use enzyme for tests instead of react-test-renderer

This commit is contained in:
Alexander Zobnin 2018-09-07 14:31:56 +03:00
parent 729cc94daf
commit 349b2787cb
No known key found for this signature in database
GPG Key ID: E17E9ABACEFA59EB
2 changed files with 111 additions and 82 deletions

View File

@ -1,16 +1,15 @@
import React from 'react';
import renderer from 'react-test-renderer';
import { mount } from 'enzyme';
import toJson from 'enzyme-to-json';
import GrafanaScrollbar from './GrafanaScrollbar';
describe('GrafanaScrollbar', () => {
it('renders correctly', () => {
const tree = renderer
.create(
const tree = mount(
<GrafanaScrollbar>
<p>Scrollable content</p>
</GrafanaScrollbar>
)
.toJSON();
expect(tree).toMatchSnapshot();
);
expect(toJson(tree)).toMatchSnapshot();
});
});

View File

@ -1,7 +1,32 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`GrafanaScrollbar renders correctly 1`] = `
<div
<GrafanaScrollbar
autoHide={true}
autoHideDuration={200}
autoHideTimeout={200}
customClassName="custom-scrollbars"
hideTracksWhenNotNeeded={false}
>
<Scrollbars
autoHeight={true}
autoHeightMax="100%"
autoHeightMin="100%"
autoHide={true}
autoHideDuration={200}
autoHideTimeout={200}
className="custom-scrollbars"
hideTracksWhenNotNeeded={false}
renderThumbHorizontal={[Function]}
renderThumbVertical={[Function]}
renderTrackHorizontal={[Function]}
renderTrackVertical={[Function]}
renderView={[Function]}
tagName="div"
thumbMinSize={30}
universal={false}
>
<div
className="custom-scrollbars"
style={
Object {
@ -13,9 +38,10 @@ exports[`GrafanaScrollbar renders correctly 1`] = `
"width": "100%",
}
}
>
>
<div
className="view"
key="view"
style={
Object {
"WebkitOverflowScrolling": "touch",
@ -38,6 +64,7 @@ exports[`GrafanaScrollbar renders correctly 1`] = `
</div>
<div
className="track-horizontal"
key="trackHorizontal"
style={
Object {
"display": "none",
@ -61,6 +88,7 @@ exports[`GrafanaScrollbar renders correctly 1`] = `
</div>
<div
className="track-vertical"
key="trackVertical"
style={
Object {
"display": "none",
@ -82,5 +110,7 @@ exports[`GrafanaScrollbar renders correctly 1`] = `
}
/>
</div>
</div>
</div>
</Scrollbars>
</GrafanaScrollbar>
`;