packages,plugins: migrate to using TestApiProvider and Registry
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -22,8 +22,8 @@ import OfflineIcon from '@material-ui/icons/Storage';
|
||||
import React from 'react';
|
||||
import { EntityTodoContent, todoApiRef, todoPlugin } from '../src';
|
||||
|
||||
import { ApiProvider, ApiRegistry } from '@backstage/core-app-api';
|
||||
import { Content, Header, HeaderLabel, Page } from '@backstage/core-components';
|
||||
import { TestApiProvider } from '@backstage/test-utils';
|
||||
|
||||
const entity: Entity = {
|
||||
apiVersion: 'backstage.io/v1alpha1',
|
||||
@@ -60,7 +60,7 @@ createDevApp()
|
||||
.registerPlugin(todoPlugin)
|
||||
.addPage({
|
||||
element: (
|
||||
<ApiProvider apis={ApiRegistry.with(todoApiRef, mockedApi)}>
|
||||
<TestApiProvider apis={[[todoApiRef, mockedApi]]}>
|
||||
<EntityProvider entity={entity}>
|
||||
<Page themeId="service">
|
||||
<Header title="Mocked TODO Data">
|
||||
@@ -71,7 +71,7 @@ createDevApp()
|
||||
</Content>
|
||||
</Page>
|
||||
</EntityProvider>
|
||||
</ApiProvider>
|
||||
</TestApiProvider>
|
||||
),
|
||||
title: 'Entity Todo Content',
|
||||
icon: OfflineIcon,
|
||||
|
||||
@@ -16,11 +16,10 @@
|
||||
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { EntityProvider } from '@backstage/plugin-catalog-react';
|
||||
import { renderWithEffects } from '@backstage/test-utils';
|
||||
import { renderWithEffects, TestApiProvider } from '@backstage/test-utils';
|
||||
import React from 'react';
|
||||
import { TodoApi, todoApiRef } from '../../api';
|
||||
import { TodoList } from './TodoList';
|
||||
import { ApiProvider, ApiRegistry } from '@backstage/core-app-api';
|
||||
|
||||
describe('TodoList', () => {
|
||||
it('should render', async () => {
|
||||
@@ -42,11 +41,11 @@ describe('TodoList', () => {
|
||||
const mockEntity = { metadata: { name: 'mock' } } as Entity;
|
||||
|
||||
const rendered = await renderWithEffects(
|
||||
<ApiProvider apis={ApiRegistry.with(todoApiRef, mockApi)}>
|
||||
<TestApiProvider apis={[[todoApiRef, mockApi]]}>
|
||||
<EntityProvider entity={mockEntity}>
|
||||
<TodoList />
|
||||
</EntityProvider>
|
||||
</ApiProvider>,
|
||||
</TestApiProvider>,
|
||||
);
|
||||
|
||||
await expect(rendered.findByText('FIXME')).resolves.toBeInTheDocument();
|
||||
|
||||
Reference in New Issue
Block a user