Skip to content

Commit 02be746

Browse files
committed
test(Charts): render all charts and migrate to react testing library
1 parent 07c5b6a commit 02be746

File tree

24 files changed

+7997
-1183
lines changed

24 files changed

+7997
-1183
lines changed
Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,43 @@
1-
import { mount } from 'enzyme';
1+
import { render } from '@shared/tests';
22
import * as React from 'react';
33
import { complexDataSet } from '../../resources/DemoProps';
44
import { BarChart } from './BarChart';
55

66
describe('BarRechart', () => {
77
test('Renders with data', () => {
8-
expect(
9-
mount(
10-
<BarChart
11-
dataset={complexDataSet}
12-
style={{ width: '50%' }}
13-
dimensions={[
14-
{
15-
accessor: 'name',
16-
interval: 0
17-
}
18-
]}
19-
measures={[
20-
{
21-
accessor: 'users',
22-
label: 'Users',
23-
formatter: (val) => val.toLocaleString()
24-
},
25-
{
26-
accessor: 'sessions',
27-
label: 'Active Sessions',
28-
formatter: (val) => `${val} sessions`,
29-
hideDataLabel: true
30-
},
31-
{
32-
accessor: 'volume',
33-
label: 'Vol.'
34-
}
35-
]}
36-
/>
37-
).render()
38-
).toMatchSnapshot();
8+
const utils = render(
9+
<BarChart
10+
dataset={complexDataSet}
11+
dimensions={[
12+
{
13+
accessor: 'name',
14+
interval: 0
15+
}
16+
]}
17+
measures={[
18+
{
19+
accessor: 'users',
20+
label: 'Users',
21+
formatter: (val) => val.toLocaleString()
22+
},
23+
{
24+
accessor: 'sessions',
25+
label: 'Active Sessions',
26+
formatter: (val) => `${val} sessions`,
27+
hideDataLabel: true
28+
},
29+
{
30+
accessor: 'volume',
31+
label: 'Vol.'
32+
}
33+
]}
34+
/>
35+
);
36+
expect(utils.asFragment()).toMatchSnapshot();
3937
});
4038

4139
test('loading placeholder', () => {
42-
const wrapper = mount(<BarChart style={{ width: '30%' }} dimensions={[]} measures={[]} />);
43-
expect(wrapper.render()).toMatchSnapshot();
40+
const wrapper = render(<BarChart dimensions={[]} measures={[]} />);
41+
expect(wrapper.asFragment()).toMatchSnapshot();
4442
});
4543
});

0 commit comments

Comments
 (0)