Skip to content

Commit 7e02d88

Browse files
Merge pull request #2407 from OneCommunityGlobal/aaryaneil-PieChartInfoDetail-UnitTest
Aaryaneil PieChartInfoDetail unit test
2 parents 55a6eaa + 49d7d46 commit 7e02d88

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import React from 'react';
2+
import { render } from '@testing-library/react';
3+
import '@testing-library/jest-dom/extend-expect';
4+
import PieChartInfoDetail from '../PieChartInfoDetail';
5+
6+
describe('PieChartInfoDetail Component', () => {
7+
test('test_render_keyName_and_value', () => {
8+
const { getByText } = render(<PieChartInfoDetail keyName="Test Key" value="123" color="#000000" darkMode={false} />);
9+
expect(getByText('Test Key')).toBeInTheDocument();
10+
expect(getByText('123')).toBeInTheDocument();
11+
});
12+
13+
test('test_apply_darkMode_class', () => {
14+
const { getByText } = render(<PieChartInfoDetail keyName="Test Key" value="123" color="#000000" darkMode={true} />);
15+
expect(getByText('Test Key')).toHaveClass('text-light');
16+
expect(getByText('123')).toHaveClass('text-light');
17+
});
18+
19+
test('test_apply_legend_square_color', () => {
20+
const { container } = render(<PieChartInfoDetail keyName="Test Key" value="123" color="#ff0000" darkMode={false} />);
21+
const legendSquare = container.querySelector('.pie-chart-legend-color-square');
22+
expect(legendSquare).toHaveStyle('background-color: #ff0000');
23+
});
24+
25+
test('test_render_keyName_and_value_with_darkMode', () => {
26+
const { getByText } = render(<PieChartInfoDetail keyName="Test Key" value="123" color="#000000" darkMode={true} />);
27+
expect(getByText('Test Key')).toBeInTheDocument();
28+
expect(getByText('123')).toBeInTheDocument();
29+
expect(getByText('Test Key')).toHaveClass('text-light');
30+
expect(getByText('123')).toHaveClass('text-light');
31+
});
32+
33+
test('test_render_with_specific_margin_styles', () => {
34+
const { getByText } = render(<PieChartInfoDetail keyName="Test Key" value="123" color="#000000" darkMode={false} />);
35+
const valueElement = getByText('123');
36+
expect(valueElement).toHaveStyle('margin-top: 16px');
37+
expect(valueElement).toHaveStyle('margin-left: 120px');
38+
});
39+
40+
test('test_render_with_different_color_and_darkMode_combinations', () => {
41+
const { getByText } = render(<PieChartInfoDetail keyName="Test Key" value="123" color="#00ff00" darkMode={true} />);
42+
expect(getByText('Test Key')).toBeInTheDocument();
43+
expect(getByText('123')).toBeInTheDocument();
44+
expect(getByText('Test Key')).toHaveClass('text-light');
45+
expect(getByText('123')).toHaveClass('text-light');
46+
});
47+
48+
test('test_apply_special_key_class_when_keyName_is_Special', () => {
49+
const { getByText } = render(<PieChartInfoDetail keyName="Special" value="123" color="#000000" darkMode={false} />);
50+
expect(getByText('Special')).toHaveClass('pie-chart-info-key');
51+
});
52+
});

0 commit comments

Comments
 (0)