chore: missed updating some of those tests

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2021-06-03 11:34:13 +02:00
parent 1ff7d88c57
commit 5312c627f8
@@ -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<TechRadarLoaderResponse> {
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(
<ThemeProvider theme={lightTheme}>
<RadarPage {...techRadarProps} />
<ApiProvider apis={ApiRegistry.from([[techRadarApiRef, mockClient]])}>
<RadarPage {...techRadarProps} />
</ApiProvider>
</ThemeProvider>,
),
);
@@ -72,7 +86,9 @@ describe('RadarPage', () => {
const { getByText, getByTestId } = await renderInTestApp(
<ThemeProvider theme={lightTheme}>
<RadarPage {...techRadarProps} />
<ApiProvider apis={ApiRegistry.from([[techRadarApiRef, mockClient]])}>
<RadarPage {...techRadarProps} />
</ApiProvider>
</ThemeProvider>,
);
@@ -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(
<ThemeProvider theme={lightTheme}>
<ApiProvider apis={ApiRegistry.with(errorApiRef, errorApi)}>
<ApiProvider
apis={ApiRegistry.from([
[errorApiRef, errorApi],
[techRadarApiRef, mockClient],
])}
>
<RadarPage {...techRadarProps} />
</ApiProvider>
</ThemeProvider>,