diff --git a/plugins/tech-radar/src/components/RadarPage.test.tsx b/plugins/tech-radar/src/components/RadarPage.test.tsx index 918015001b..b5169fadd9 100644 --- a/plugins/tech-radar/src/components/RadarPage.test.tsx +++ b/plugins/tech-radar/src/components/RadarPage.test.tsx @@ -27,6 +27,7 @@ import React from 'react'; import { act } from 'react-dom/test-utils'; import GetBBoxPolyfill from '../utils/polyfills/getBBox'; import { RadarPage } from './RadarPage'; +import { TechRadarLoaderResponse, techRadarApiRef, TechRadarApi } from '../api'; describe('RadarPage', () => { beforeAll(() => { @@ -36,6 +37,17 @@ describe('RadarPage', () => { afterAll(() => { GetBBoxPolyfill.remove(); }); + class MockClient implements TechRadarApi { + async load(): Promise { + return { + entries: [], + quadrants: [], + rings: [], + }; + } + } + + const mockClient = new MockClient(); it('should render a progress bar', async () => { jest.useFakeTimers(); @@ -49,7 +61,9 @@ describe('RadarPage', () => { const { getByTestId, queryByTestId } = render( wrapInTestApp( - + + + , ), ); @@ -72,7 +86,9 @@ describe('RadarPage', () => { const { getByText, getByTestId } = await renderInTestApp( - + + + , ); @@ -86,18 +102,25 @@ describe('RadarPage', () => { it('should call the errorApi if load fails', async () => { const errorApi = new MockErrorApi({ collect: true }); - const techRadarLoadFail = () => - Promise.reject(new Error('404 Page Not Found')); + + jest + .spyOn(mockClient, 'load') + .mockRejectedValue(new Error('404 Page Not Found')); + const techRadarProps = { width: 1200, height: 800, - getData: techRadarLoadFail, svgProps: { 'data-testid': 'tech-radar-svg' }, }; const { queryByTestId } = await renderInTestApp( - + ,