Test update, JSX.Element -> ReactNode

Signed-off-by: Tim Hansen <timbonicus@gmail.com>
This commit is contained in:
Tim Hansen
2021-08-28 22:19:51 -06:00
parent e6c88df016
commit 7febe58d6e
5 changed files with 13 additions and 31 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
'@backstage/core-components': minor
---
Changed the `titleComponent` prop on `ContentHeader` to accept `JSX.Element` instead of a React `ComponentType`. Usages of this prop should be converted from passing a component to passing in the rendered element:
Changed the `titleComponent` prop on `ContentHeader` to accept `ReactNode` instead of a React `ComponentType`. Usages of this prop should be converted from passing a component to passing in the rendered element:
```diff
-<ContentHeader titleComponent={MyComponent}>
@@ -18,7 +18,7 @@
* TODO favoriteable capability
*/
import React, { PropsWithChildren } from 'react';
import React, { PropsWithChildren, ReactNode } from 'react';
import { Typography, makeStyles } from '@material-ui/core';
import { Helmet } from 'react-helmet';
@@ -77,7 +77,7 @@ const ContentHeaderTitle = ({
type ContentHeaderProps = {
title?: ContentHeaderTitleProps['title'];
titleComponent?: JSX.Element;
titleComponent?: ReactNode;
description?: string;
textAlign?: 'left' | 'right' | 'center';
};
@@ -61,22 +61,11 @@ const entities: Entity[] = [
},
];
const apis = ApiRegistry.from([
[
catalogApiRef,
{
getEntities: jest
.fn()
.mockImplementation(() => Promise.resolve({ items: entities })),
} as unknown as CatalogApi,
],
[
alertApiRef,
{
post: jest.fn(),
} as unknown as AlertApi,
],
]);
const apis = ApiRegistry.with(catalogApiRef, {
getEntities: jest.fn().mockResolvedValue({ items: entities }),
} as unknown as CatalogApi).with(alertApiRef, {
post: jest.fn(),
} as unknown as AlertApi);
describe('<EntityTypePicker/>', () => {
it('renders available entity types', async () => {
@@ -54,12 +54,12 @@ const entities: Entity[] = [
];
const mockCatalogApi: Partial<CatalogApi> = {
getEntities: jest.fn().mockImplementation(async () => ({ items: entities })),
getEntities: jest.fn().mockResolvedValue({ items: entities }),
};
const wrapper = ({ children }: PropsWithChildren<{}>) => {
return (
<ApiProvider apis={ApiRegistry.from([[catalogApiRef, mockCatalogApi]])}>
<ApiProvider apis={ApiRegistry.with(catalogApiRef, mockCatalogApi)}>
{children}
</ApiProvider>
);
@@ -58,16 +58,9 @@ const entities: Entity[] = [
},
];
const apis = ApiRegistry.from([
[
catalogApiRef,
{
getEntities: jest
.fn()
.mockImplementation(() => Promise.resolve({ items: entities })),
} as Partial<CatalogApi>,
],
]);
const apis = ApiRegistry.with(catalogApiRef, {
getEntities: jest.fn().mockResolvedValue({ items: entities }),
} as Partial<CatalogApi>);
describe('<CatalogKindHeader />', () => {
it('renders available kinds', async () => {