Skip to content

Commit

Permalink
Merge pull request #759 from Abhinandan-Kushwaha/development
Browse files Browse the repository at this point in the history
v1.4.26 added hidePointers to dataSet & fixes & updated tests
  • Loading branch information
Abhinandan-Kushwaha authored Aug 4, 2024
2 parents eaebe80 + cbcabd1 commit dece9e1
Show file tree
Hide file tree
Showing 17 changed files with 61,225 additions and 32,316 deletions.
25 changes: 25 additions & 0 deletions __tests__/BarChart.test.js → __tests__/BarChart.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ import RoundStackBar from '../examples/BarChart/RoundStackBar';
import SimpleBlueBars from '../examples/BarChart/SimpleBlueBars';
import SimpleBlueBarsVerticalLines from '../examples/BarChart/SimpleBlueBarsVerticalLines';
import BarChartWithGivenNumberOfVerticalLines from '../examples/BarChart/BarChartWithGivenNumberOfVerticalLines';
import BarPairWithLine from '../examples/BarChart/BarPairWithLine';
import StackPairWithPattern from '../examples/BarChart/StackPairWithPattern';
import StackWithNegative from '../examples/BarChart/StackWithNegative';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
import ShiftXaxisLabels from '../examples/BarChart/ShiftXaxisLabels';

describe('Bar and Stacked Bar chart tests', () => {
it('renders 3D bar chart correctly', () => {
Expand Down Expand Up @@ -52,4 +56,25 @@ describe('Bar and Stacked Bar chart tests', () => {
.toJSON();
expect(tree).toMatchSnapshot();
});

it('renders a Bar chart combined with Line chart', () => {
const tree = renderer.create(<BarPairWithLine />).toJSON();
expect(tree).toMatchSnapshot();
});

it('renders a Bar chart with shifted X axis labels', () => {
const tree = renderer.create(<ShiftXaxisLabels />).toJSON();
expect(tree).toMatchSnapshot();
});

it('renders a stacked Bar chart with patterns', () => {
const tree = renderer.create(<StackPairWithPattern />).toJSON();
expect(tree).toMatchSnapshot();
});


it('renders a stacked Bar chart with negative values', () => {
const tree = renderer.create(<StackWithNegative />).toJSON();
expect(tree).toMatchSnapshot();
});
});
61 changes: 61 additions & 0 deletions __tests__/LineChart.test.js → __tests__/LineChart.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,50 +12,111 @@ import ChartWithAdjustingPointer from '../examples/LineChart/ChartWithAdjustingP
import ScrollingChartWithPointer from '../examples/LineChart/ScrollingChartWithPointer';
import CaloriesBurnt from '../examples/LineChart/CaloriesBurnt';
import SimpleBlueLineWithGivenNumberOfVerticalLines from '../examples/LineChart/SimpleBlueLineWithGivenNumberOfVerticalLines';
import DataSetSteppedChart from '../examples/LineChart/DataSetSteppedChart';
import HighlightedRange from '../examples/LineChart/HighlightedRange';
import SecondaryLineChart from '../examples/LineChart/SecondaryLineChart';
import SecondaryLineChartFromDataSet from '../examples/LineChart/SecondaryLineChartFromDataSet';
import Segmented from '../examples/LineChart/Segmented';
import SegmentedDataSet from '../examples/LineChart/SegmentedDataSet';
import SegmentedDataSetCurved from '../examples/LineChart/SegmentedDataSetCurved';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';

describe('Line and Area chart tests', () => {
beforeEach(() => {
jest.useFakeTimers();
});

it('renders 2 area chart correctly', () => {
const tree = renderer.create(<AreaTwo />).toJSON();
jest.runAllTimers();
expect(tree).toMatchSnapshot();
});

it('renders 2 line chart correctly', () => {
const tree = renderer.create(<LineChartTwo />).toJSON();
jest.runAllTimers();
expect(tree).toMatchSnapshot();
});

it('renders blue line chart correctly', () => {
const tree = renderer.create(<SimpleBlueLine />).toJSON();
jest.runAllTimers();
expect(tree).toMatchSnapshot();
});

it('renders ChartWithPointer correctly', () => {
const tree = renderer.create(<ChartWithPointer />).toJSON();
jest.runAllTimers();
expect(tree).toMatchSnapshot();
});

it('renders ChartWithAdjustingPointer correctly', () => {
const tree = renderer.create(<ChartWithAdjustingPointer />).toJSON();
jest.runAllTimers();
expect(tree).toMatchSnapshot();
});

it('renders ScrollingChartWithPointer correctly', () => {
const tree = renderer.create(<ScrollingChartWithPointer />).toJSON();
jest.runAllTimers();
expect(tree).toMatchSnapshot();
});

it('renders CaloriesBurnt Area chart correctly', () => {
const tree = renderer.create(<CaloriesBurnt />).toJSON();
jest.runAllTimers();
expect(tree).toMatchSnapshot();
});

it('renders blue line chart with given number of vertical lines correctly', () => {
const tree = renderer
.create(<SimpleBlueLineWithGivenNumberOfVerticalLines />)
.toJSON();
jest.runAllTimers();
expect(tree).toMatchSnapshot();
});

it('renders a stepped chart with dataSet', () => {
const tree = renderer.create(<DataSetSteppedChart />).toJSON();
jest.runAllTimers();
expect(tree).toMatchSnapshot();
});

it('renders a chart with highlighted range', () => {
const tree = renderer.create(<HighlightedRange />).toJSON();
jest.runAllTimers();
expect(tree).toMatchSnapshot();
});

it('renders a chart with secondary Y axis and secondary line', () => {
const tree = renderer.create(<SecondaryLineChart />).toJSON();
jest.runAllTimers();
expect(tree).toMatchSnapshot();
});

it('renders a chart with secondary Y axis and secondary line using dataSet', () => {
const tree = renderer.create(<SecondaryLineChartFromDataSet />).toJSON();
jest.runAllTimers();
expect(tree).toMatchSnapshot();
});

it('renders a segmented chart', () => {
const tree = renderer.create(<Segmented />).toJSON();
jest.runAllTimers();
expect(tree).toMatchSnapshot();
});

it('renders a segmented chart with dataSet', () => {
const tree = renderer.create(<SegmentedDataSet />).toJSON();
jest.runAllTimers();
expect(tree).toMatchSnapshot();
});

it('renders a curved segmented chart with dataSet', () => {
const tree = renderer.create(<SegmentedDataSetCurved />).toJSON();
jest.runAllTimers();
expect(tree).toMatchSnapshot();
});
});
13 changes: 13 additions & 0 deletions __tests__/PieChart.test.js → __tests__/PieChart.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import SimplePie from '../examples/PieChart/SimplePie';
import SplitPie from '../examples/PieChart/SplitPie';
import ThreeDPie from '../examples/PieChart/ThreeDPie';
import PieSingleData from '../examples/PieChart/PieSingleData';
import PieWithZero from '../examples/PieChart/PieWithZero';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
Expand All @@ -19,26 +20,38 @@ describe('Pie and Donut chart tests', () => {
});
it('renders progress pie chart correctly', () => {
const tree = renderer.create(<ProgressPie />).toJSON();
jest.runAllTimers();
expect(tree).toMatchSnapshot();
});

it('renders simple pie chart correctly', () => {
const tree = renderer.create(<SimplePie />).toJSON();
jest.runAllTimers();
expect(tree).toMatchSnapshot();
});

it('renders split pie chart correctly', () => {
const tree = renderer.create(<SplitPie />).toJSON();
jest.runAllTimers();
expect(tree).toMatchSnapshot();
});

it('renders 3D pie chart correctly', () => {
const tree = renderer.create(<ThreeDPie />).toJSON();
jest.runAllTimers();
expect(tree).toMatchSnapshot();
});

it('renders pie chart correctly for Single data', () => {
const tree = renderer.create(<PieSingleData />).toJSON();
jest.runAllTimers();
expect(tree).toMatchSnapshot();
});

it('renders pie chart with zero values correctly', () => {
const tree = renderer.create(<PieWithZero />).toJSON();
jest.runAllTimers();
expect(tree).toMatchSnapshot();
});

});
Loading

0 comments on commit dece9e1

Please sign in to comment.