From 7febe58d6e8fcb12b856a2092802e03947937ee9 Mon Sep 17 00:00:00 2001 From: Tim Hansen Date: Sat, 28 Aug 2021 22:19:51 -0600 Subject: [PATCH] Test update, JSX.Element -> ReactNode Signed-off-by: Tim Hansen --- .changeset/nasty-ads-nail.md | 2 +- .../layout/ContentHeader/ContentHeader.tsx | 4 ++-- .../EntityTypePicker.test.tsx | 21 +++++-------------- .../src/hooks/useEntityKinds.test.tsx | 4 ++-- .../CatalogKindHeader.test.tsx | 13 +++--------- 5 files changed, 13 insertions(+), 31 deletions(-) diff --git a/.changeset/nasty-ads-nail.md b/.changeset/nasty-ads-nail.md index e59a54ed84..0518b1e569 100644 --- a/.changeset/nasty-ads-nail.md +++ b/.changeset/nasty-ads-nail.md @@ -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 - diff --git a/packages/core-components/src/layout/ContentHeader/ContentHeader.tsx b/packages/core-components/src/layout/ContentHeader/ContentHeader.tsx index 5891e801e1..2259731148 100644 --- a/packages/core-components/src/layout/ContentHeader/ContentHeader.tsx +++ b/packages/core-components/src/layout/ContentHeader/ContentHeader.tsx @@ -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'; }; diff --git a/plugins/catalog-react/src/components/EntityTypePicker/EntityTypePicker.test.tsx b/plugins/catalog-react/src/components/EntityTypePicker/EntityTypePicker.test.tsx index a9ecf03e5c..9912f3d371 100644 --- a/plugins/catalog-react/src/components/EntityTypePicker/EntityTypePicker.test.tsx +++ b/plugins/catalog-react/src/components/EntityTypePicker/EntityTypePicker.test.tsx @@ -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('', () => { it('renders available entity types', async () => { diff --git a/plugins/catalog-react/src/hooks/useEntityKinds.test.tsx b/plugins/catalog-react/src/hooks/useEntityKinds.test.tsx index 96281f4a5a..d801e508a6 100644 --- a/plugins/catalog-react/src/hooks/useEntityKinds.test.tsx +++ b/plugins/catalog-react/src/hooks/useEntityKinds.test.tsx @@ -54,12 +54,12 @@ const entities: Entity[] = [ ]; const mockCatalogApi: Partial = { - getEntities: jest.fn().mockImplementation(async () => ({ items: entities })), + getEntities: jest.fn().mockResolvedValue({ items: entities }), }; const wrapper = ({ children }: PropsWithChildren<{}>) => { return ( - + {children} ); diff --git a/plugins/catalog/src/components/CatalogKindHeader/CatalogKindHeader.test.tsx b/plugins/catalog/src/components/CatalogKindHeader/CatalogKindHeader.test.tsx index c15c50a239..2730665fb6 100644 --- a/plugins/catalog/src/components/CatalogKindHeader/CatalogKindHeader.test.tsx +++ b/plugins/catalog/src/components/CatalogKindHeader/CatalogKindHeader.test.tsx @@ -58,16 +58,9 @@ const entities: Entity[] = [ }, ]; -const apis = ApiRegistry.from([ - [ - catalogApiRef, - { - getEntities: jest - .fn() - .mockImplementation(() => Promise.resolve({ items: entities })), - } as Partial, - ], -]); +const apis = ApiRegistry.with(catalogApiRef, { + getEntities: jest.fn().mockResolvedValue({ items: entities }), +} as Partial); describe('', () => { it('renders available kinds', async () => {