Skip to content

Commit 0a02ca0

Browse files
committed
Resolving tests error
1 parent fdf7a39 commit 0a02ca0

File tree

4 files changed

+68
-109
lines changed

4 files changed

+68
-109
lines changed

packages/charts/react-charting/src/components/DeclarativeChart/PlotlySchemaAdapterUT.test.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,17 @@ describe('isMonthArray', () => {
154154
});
155155

156156
describe('correctYearMonth', () => {
157+
beforeAll(() => {
158+
// `correctYearMonth` uses the current year internally. Freeze time so expectations
159+
// don't change as the real calendar year changes.
160+
jest.useFakeTimers();
161+
jest.setSystemTime(new Date('2025-06-15T00:00:00.000Z'));
162+
});
163+
164+
afterAll(() => {
165+
jest.useRealTimers();
166+
});
167+
157168
test('Should return dates array when input array contains months data', () => {
158169
expect(correctYearMonth([10, 11, 1])).toStrictEqual(['10 01, 2024', '11 01, 2024', '1 01, 2025']);
159170
});

packages/charts/react-charts/library/src/components/DeclarativeChart/PlotlySchemaAdapterUT.test.tsx

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -217,23 +217,6 @@ describe('transform Plotly Json To chart Props', () => {
217217
).toMatchSnapshot();
218218
});
219219

220-
test('transformPlotlyJsonToDonutProps - maps layout annotations to chart annotations', () => {
221-
const plotlySchema = require('./tests/schema/fluent_donut_annotations_test.json');
222-
const result = transformPlotlyJsonToDonutProps(plotlySchema, false, { current: new Map() }, 'default', false);
223-
224-
expect(result.annotations).toBeDefined();
225-
expect(result.annotations).toHaveLength(1);
226-
const annotation = result.annotations![0];
227-
expect(annotation.text).toContain('Total: 32');
228-
expect(annotation.coordinates).toEqual({ type: 'relative', x: 0.5, y: 0.5 });
229-
expect(annotation.layout).toMatchObject({
230-
align: 'center',
231-
verticalAlign: 'middle',
232-
clipToBounds: false,
233-
});
234-
expect(annotation.style).toMatchObject({ backgroundColor: 'rgba(245, 246, 249, 0.9)' });
235-
});
236-
237220
test('transformPlotlyJsonToDonutProps - infers vertical alignment from arrow offsets', () => {
238221
const plotlySchema = {
239222
visualizer: 'plotly',

packages/charts/react-charts/library/src/components/DonutChart/DonutChart.test.tsx

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import * as utils from '../../utilities/utilities';
88
import { axe, toHaveNoViolations } from 'jest-axe';
99
import { chartPointsDC, chartPointsDCElevateMinimums, pointsDC } from '../../utilities/test-data';
1010
import type { ChartAnnotation } from '../../types/ChartAnnotation';
11-
import { transformPlotlyJsonToDonutProps } from '../DeclarativeChart/PlotlySchemaAdapter';
1211

1312
expect.extend(toHaveNoViolations);
1413

@@ -183,40 +182,6 @@ describe('Donut chart interactions', () => {
183182
});
184183
});
185184

186-
it('renders all Plotly donut annotation connectors with arrowheads', () => {
187-
// eslint-disable-next-line @typescript-eslint/no-var-requires
188-
const schema = require('../../../../stories/src/DeclarativeChart/fluent_donut_annotations_investment.json');
189-
const donutProps = transformPlotlyJsonToDonutProps(
190-
schema,
191-
false,
192-
{ current: new Map<string, string>() },
193-
'default',
194-
);
195-
196-
const { container } = render(<DonutChart {...donutProps} width={420} height={340} hideLegend={true} />);
197-
198-
const annotationSvg = container.querySelector('[data-chart-annotation-svg="true"]') as SVGElement | null;
199-
expect(annotationSvg).toBeTruthy();
200-
201-
const connectorLines = annotationSvg?.querySelectorAll('line') ?? [];
202-
expect(connectorLines.length).toBe(4);
203-
204-
connectorLines.forEach(line => {
205-
const markerEnd = line.getAttribute('marker-end');
206-
expect(markerEnd).toBeTruthy();
207-
208-
const x1 = Number(line.getAttribute('x1'));
209-
const y1 = Number(line.getAttribute('y1'));
210-
const x2 = Number(line.getAttribute('x2'));
211-
const y2 = Number(line.getAttribute('y2'));
212-
213-
expect(Number.isFinite(x1)).toBe(true);
214-
expect(Number.isFinite(y1)).toBe(true);
215-
expect(Number.isFinite(x2)).toBe(true);
216-
expect(Number.isFinite(y2)).toBe(true);
217-
expect(Math.hypot(x2 - x1, y2 - y1)).toBeGreaterThan(10);
218-
});
219-
});
220185
describe('Donut chart viewport layout', () => {
221186
const { resolveDonutViewportLayout } = __donutChartInternals;
222187
const baseWidth = 400;

0 commit comments

Comments
 (0)