Skip to content

Commit a7b928f

Browse files
Wrote snapshot tests for 6 bar, 4 line and 4 pie charts
1 parent 9e9c0a1 commit a7b928f

15 files changed

+17849
-30
lines changed

App.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,21 @@ import React, {useEffect, useState} from 'react';
22
import {ScrollView, TouchableOpacity} from 'react-native';
33
import {Alert} from 'react-native';
44
import {View, Text, StyleSheet} from 'react-native';
5-
import {MyPattern} from './src/pattern';
65
import {BarChart, LineChart, PieChart} from './src';
76
import {Path, Pattern} from 'react-native-svg';
7+
import BarWithGradient from './examples/BarChart/BarWithGradient';
8+
import CappedBars from './examples/BarChart/CappedBars';
9+
import RoundStackBar from './examples/BarChart/RoundStackBar';
10+
import SimpleBarAnimated from './examples/BarChart/SimpleBarAnimated';
11+
import SimpleBlueBars from './examples/BarChart/SimpleBlueBars';
12+
import AnimatedArea from './examples/LineChart/AnimatedArea';
13+
import AreaTwo from './examples/LineChart/AreaTwo';
14+
import LineChartTwo from './examples/LineChart/LineChartTwo';
15+
import SimpleBlueLine from './examples/LineChart/SimpleBlueLine';
16+
import ProgressPie from './examples/PieChart/ProgressPie';
17+
import SimplePie from './examples/PieChart/SimplePie';
18+
import SplitPie from './examples/PieChart/SplitPie';
19+
import ThreeDPie from './examples/PieChart/ThreeDPie';
820

921
const App = () => {
1022
const [toggle, setToggle] = useState(true);
@@ -982,7 +994,21 @@ const App = () => {
982994
// backgroundColor: '#1C1C1C',
983995
}}>
984996
{/* <PieChart data={llData}/> */}
985-
<LineChart data={drata} yAxisOffset={100} />
997+
{/* <BarThreeD/> */}
998+
{/* <BarWithGradient /> */}
999+
{/* <CappedBars /> */}
1000+
{/* <RoundStackBar /> */}
1001+
{/* <SimpleBarAnimated /> */}
1002+
{/* <SimpleBlueBars /> */}
1003+
{/* <AnimatedArea /> */}
1004+
{/* <AreaTwo /> */}
1005+
{/* <LineChartTwo /> */}
1006+
{/* <SimpleBlueLine /> */}
1007+
{/* <ProgressPie /> */}
1008+
{/* <SimplePie /> */}
1009+
{/* <SplitPie /> */}
1010+
{/* <ThreeDPie /> */}
1011+
<LineChart data={drata} yAxisOffset={120} />
9861012
{/* <LineChart
9871013
areaChart
9881014
curved

__tests__/App-test.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

__tests__/BarChart.test.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* @format
3+
*/
4+
5+
import 'react-native';
6+
import React from 'react';
7+
import BarThreeD from '../examples/BarChart/BarThreeD';
8+
import BarWithGradient from '../examples/BarChart/BarWithGradient';
9+
import CappedBars from '../examples/BarChart/CappedBars';
10+
import RoundStackBar from '../examples/BarChart/RoundStackBar';
11+
import SimpleBarAnimated from '../examples/BarChart/SimpleBarAnimated';
12+
import SimpleBlueBars from '../examples/BarChart/SimpleBlueBars';
13+
14+
// Note: test renderer must be required after react-native.
15+
import renderer from 'react-test-renderer';
16+
17+
it('renders 3D bar chart correctly', () => {
18+
const tree = renderer.create(<BarThreeD />).toJSON();
19+
expect(tree).toMatchSnapshot();
20+
});
21+
22+
it('renders gradient bar chart correctly', () => {
23+
const tree = renderer.create(<BarWithGradient />).toJSON();
24+
expect(tree).toMatchSnapshot();
25+
});
26+
27+
it('renders capped bar chart correctly', () => {
28+
const tree = renderer.create(<CappedBars />).toJSON();
29+
expect(tree).toMatchSnapshot();
30+
});
31+
32+
it('renders rounded stack bar chart correctly', () => {
33+
const tree = renderer.create(<RoundStackBar />).toJSON();
34+
expect(tree).toMatchSnapshot();
35+
});
36+
37+
it('renders simple animated bar chart correctly', () => {
38+
const tree = renderer.create(<SimpleBarAnimated />).toJSON();
39+
expect(tree).toMatchSnapshot();
40+
});
41+
42+
it('renders alternate blue and gray bar chart correctly', () => {
43+
const tree = renderer.create(<SimpleBlueBars />).toJSON();
44+
expect(tree).toMatchSnapshot();
45+
});

__tests__/LineChart.test.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* @format
3+
*/
4+
5+
import 'react-native';
6+
import React from 'react';
7+
import AnimatedArea from '../examples/LineChart/AnimatedArea';
8+
import AreaTwo from '../examples/LineChart/AreaTwo';
9+
import LineChartTwo from '../examples/LineChart/LineChartTwo';
10+
import SimpleBlueLine from '../examples/LineChart/SimpleBlueLine';
11+
12+
// Note: test renderer must be required after react-native.
13+
import renderer from 'react-test-renderer';
14+
15+
it('renders animated area chart correctly', () => {
16+
const tree = renderer.create(<AnimatedArea />).toJSON();
17+
expect(tree).toMatchSnapshot();
18+
});
19+
20+
it('renders 2 area chart correctly', () => {
21+
const tree = renderer.create(<AreaTwo />).toJSON();
22+
expect(tree).toMatchSnapshot();
23+
});
24+
25+
it('renders 2 line chart correctly', () => {
26+
const tree = renderer.create(<LineChartTwo />).toJSON();
27+
expect(tree).toMatchSnapshot();
28+
});
29+
30+
it('renders blue line chart correctly', () => {
31+
const tree = renderer.create(<SimpleBlueLine />).toJSON();
32+
expect(tree).toMatchSnapshot();
33+
});

__tests__/PieChart.test.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* @format
3+
*/
4+
5+
import 'react-native';
6+
import React from 'react';
7+
import ProgressPie from '../examples/PieChart/ProgressPie';
8+
import SimplePie from '../examples/PieChart/SimplePie';
9+
import SplitPie from '../examples/PieChart/SplitPie';
10+
import ThreeDPie from '../examples/PieChart/ThreeDPie';
11+
12+
// Note: test renderer must be required after react-native.
13+
import renderer from 'react-test-renderer';
14+
15+
it('renders progress pie chart correctly', () => {
16+
const tree = renderer.create(<ProgressPie />).toJSON();
17+
expect(tree).toMatchSnapshot();
18+
});
19+
20+
it('renders simple pie chart correctly', () => {
21+
const tree = renderer.create(<SimplePie />).toJSON();
22+
expect(tree).toMatchSnapshot();
23+
});
24+
25+
it('renders split pie chart correctly', () => {
26+
const tree = renderer.create(<SplitPie />).toJSON();
27+
expect(tree).toMatchSnapshot();
28+
});
29+
30+
it('renders #D pie chart correctly', () => {
31+
const tree = renderer.create(<ThreeDPie />).toJSON();
32+
expect(tree).toMatchSnapshot();
33+
});

0 commit comments

Comments
 (0)