Skip to content

Commit

Permalink
BarChart: Finish migration of test to jest (#3111)
Browse files Browse the repository at this point in the history
Jest Migration: 

Following the pattern of my previous PR
#3106, I:
- remove redundant tests
- fix issues in the jest test
- implement a missing test that was commented out.
  • Loading branch information
Nikolas Rieble committed Dec 22, 2022
1 parent 0d06c55 commit b341920
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 241 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
/* eslint-disable import/no-useless-path-segments */
/* eslint-disable import/order */
/* eslint-disable no-return-assign */
/* eslint-disable react/prop-types */
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable react/jsx-filename-extension */
/* eslint-disable no-undef */
import React from 'react';
import { BarChart, Bar, XAxis, YAxis } from '../../../src';
import { render } from '@testing-library/react';
import React from 'react';

import { Bar, BarChart, Tooltip, XAxis, YAxis } from '../../../src';

describe('<BarChart />', () => {
const data = [
Expand Down Expand Up @@ -120,27 +115,18 @@ describe('<BarChart />', () => {
expect(container.querySelectorAll('.recharts-rectangle')).toHaveLength(4);
});

// test('Renders tooltip when Tooltip item is added', () => {
// const wrapper = mount(
// <BarChart width={100} height={50} data={data}>
// <Bar dataKey="uv" stackId="test" fill="#ff7300" />
// <Bar dataKey="pv" stackId="test" fill="#387908" />
// <Tooltip />
// </BarChart>
// );
// wrapper.setState({
// isTooltipActive: true,
// activeTooltipIndex: 3,
// activeTooltipLabel: 4,
// activeTooltipCoord: {
// x: 95,
// y: 21,
// },
// });

// expect(wrapper.find('.recharts-default-tooltip').length).to.equal(1);
// expect(wrapper.find('.recharts-tooltip-wrapper').length).to.equal(1);
// });
test('Renders tooltip when Tooltip item is added', () => {
const { container } = render(
<BarChart width={100} height={50} data={data}>
<Bar dataKey="uv" stackId="test" fill="#ff7300" />
<Bar dataKey="pv" stackId="test" fill="#387908" />
<Tooltip />
</BarChart>,
);
// Both the default Tooltip as well as the Tooltip wrapper are rendered even if not visible
expect(container.querySelectorAll('.recharts-default-tooltip')).toHaveLength(1);
expect(container.querySelectorAll('.recharts-tooltip-wrapper')).toHaveLength(1);
});

test('Render empty when data is empty', () => {
const { container } = render(
Expand Down
1 change: 0 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ require('./specs/numberAxis/FunnelSpec');

// chart
require('./specs/chart/AreaChartSpec');
require('./specs/chart/BarChartSpec');
require('./specs/chart/LineChartSpec');
require('./specs/chart/PieChartSpec');
require('./specs/chart/RadarChartSpec');
Expand Down
211 changes: 0 additions & 211 deletions test/specs/chart/BarChartSpec.js

This file was deleted.

0 comments on commit b341920

Please sign in to comment.