diff --git a/plugins/auth-backend/src/lib/catalog/CatalogIdentityClient.test.ts b/plugins/auth-backend/src/lib/catalog/CatalogIdentityClient.test.ts index e4d9304892..96cd8d32cb 100644 --- a/plugins/auth-backend/src/lib/catalog/CatalogIdentityClient.test.ts +++ b/plugins/auth-backend/src/lib/catalog/CatalogIdentityClient.test.ts @@ -24,7 +24,7 @@ import { import { CatalogIdentityClient } from './CatalogIdentityClient'; describe('CatalogIdentityClient', () => { - const catalogApi: jest.Mocked = { + const catalogApi = { getLocationById: jest.fn(), getEntityByRef: jest.fn(), getEntities: jest.fn(), @@ -48,7 +48,7 @@ describe('CatalogIdentityClient', () => { catalogApi.getEntities.mockResolvedValueOnce({ items: [{} as UserEntity] }); tokenManager.getToken.mockResolvedValue({ token: 'my-token' }); const client = new CatalogIdentityClient({ - catalogApi, + catalogApi: catalogApi as Partial as CatalogApi, tokenManager, }); @@ -106,7 +106,7 @@ describe('CatalogIdentityClient', () => { tokenManager.getToken.mockResolvedValue({ token: 'my-token' }); const client = new CatalogIdentityClient({ - catalogApi, + catalogApi: catalogApi as Partial as CatalogApi, tokenManager, }); diff --git a/plugins/badges-backend/src/service/router.test.ts b/plugins/badges-backend/src/service/router.test.ts index 9dc60ea1b5..109b64231d 100644 --- a/plugins/badges-backend/src/service/router.test.ts +++ b/plugins/badges-backend/src/service/router.test.ts @@ -29,7 +29,19 @@ import { BadgeBuilder } from '../lib'; describe('createRouter', () => { let app: express.Express; let badgeBuilder: jest.Mocked; - let catalog: jest.Mocked; + const catalog = { + addLocation: jest.fn(), + getEntities: jest.fn(), + getEntityByRef: jest.fn(), + getLocationByRef: jest.fn(), + getLocationById: jest.fn(), + removeLocationById: jest.fn(), + removeEntityByUid: jest.fn(), + refreshEntity: jest.fn(), + getEntityAncestors: jest.fn(), + getEntityFacets: jest.fn(), + validateEntity: jest.fn(), + }; let config: Config; let discovery: PluginEndpointDiscovery; @@ -57,20 +69,6 @@ describe('createRouter', () => { createBadgeJson: jest.fn(), createBadgeSvg: jest.fn(), }; - catalog = { - addLocation: jest.fn(), - getEntities: jest.fn(), - getEntityByRef: jest.fn(), - getLocationByRef: jest.fn(), - getLocationById: jest.fn(), - removeLocationById: jest.fn(), - removeEntityByUid: jest.fn(), - refreshEntity: jest.fn(), - getEntityAncestors: jest.fn(), - getEntityFacets: jest.fn(), - validateEntity: jest.fn(), - }; - config = new ConfigReader({ backend: { baseUrl: 'http://127.0.0.1', @@ -81,7 +79,7 @@ describe('createRouter', () => { const router = await createRouter({ badgeBuilder, - catalog, + catalog: catalog as Partial as CatalogApi, config, discovery, }); @@ -95,7 +93,7 @@ describe('createRouter', () => { it('works', async () => { const router = await createRouter({ badgeBuilder, - catalog, + catalog: catalog as Partial as CatalogApi, config, discovery, }); diff --git a/plugins/catalog-graph/src/components/CatalogGraphCard/CatalogGraphCard.test.tsx b/plugins/catalog-graph/src/components/CatalogGraphCard/CatalogGraphCard.test.tsx index 7cd6d29bbc..c5940be395 100644 --- a/plugins/catalog-graph/src/components/CatalogGraphCard/CatalogGraphCard.test.tsx +++ b/plugins/catalog-graph/src/components/CatalogGraphCard/CatalogGraphCard.test.tsx @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import { Entity } from '@backstage/catalog-model'; import { ApiProvider } from '@backstage/core-app-api'; import { analyticsApiRef } from '@backstage/core-plugin-api'; import { - CatalogApi, catalogApiRef, EntityProvider, entityRouteRef, @@ -36,10 +36,24 @@ import { CatalogGraphCard } from './CatalogGraphCard'; describe('', () => { let entity: Entity; let wrapper: JSX.Element; - let catalog: jest.Mocked; + const catalog = { + getEntities: jest.fn(), + getEntityByRef: jest.fn(), + removeEntityByUid: jest.fn(), + getLocationById: jest.fn(), + getLocationByRef: jest.fn(), + addLocation: jest.fn(), + removeLocationById: jest.fn(), + refreshEntity: jest.fn(), + getEntityAncestors: jest.fn(), + getEntityFacets: jest.fn(), + validateEntity: jest.fn(), + }; let apis: TestApiRegistry; beforeEach(() => { + jest.clearAllMocks(); + entity = { apiVersion: 'a', kind: 'b', @@ -48,19 +62,6 @@ describe('', () => { namespace: 'd', }, }; - catalog = { - getEntities: jest.fn(), - getEntityByRef: jest.fn(async _ => ({ ...entity, relations: [] })), - removeEntityByUid: jest.fn(), - getLocationById: jest.fn(), - getLocationByRef: jest.fn(), - addLocation: jest.fn(), - removeLocationById: jest.fn(), - refreshEntity: jest.fn(), - getEntityAncestors: jest.fn(), - getEntityFacets: jest.fn(), - validateEntity: jest.fn(), - }; apis = TestApiRegistry.from([catalogApiRef, catalog]); wrapper = ( @@ -73,6 +74,11 @@ describe('', () => { }); test('renders without exploding', async () => { + catalog.getEntityByRef.mockImplementation(async _ => ({ + ...entity, + relations: [], + })); + const { findByText, findAllByTestId } = await renderInTestApp(wrapper, { mountedRoutes: { '/entity/{kind}/{namespace}/{name}': entityRouteRef, @@ -86,6 +92,11 @@ describe('', () => { }); test('renders with custom title', async () => { + catalog.getEntityByRef.mockImplementation(async _ => ({ + ...entity, + relations: [], + })); + const { findByText } = await renderInTestApp( @@ -104,6 +115,11 @@ describe('', () => { }); test('renders link to standalone viewer', async () => { + catalog.getEntityByRef.mockImplementation(async _ => ({ + ...entity, + relations: [], + })); + const { findByText, getByText } = await renderInTestApp(wrapper, { mountedRoutes: { '/entity/{kind}/{namespace}/{name}': entityRouteRef, @@ -145,6 +161,11 @@ describe('', () => { }); test('captures analytics event on click', async () => { + catalog.getEntityByRef.mockImplementation(async _ => ({ + ...entity, + relations: [], + })); + const analyticsSpy = new MockAnalyticsApi(); const { findByText } = await renderInTestApp( diff --git a/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.test.tsx b/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.test.tsx index 9cca6ef9be..9a5d1f833e 100644 --- a/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.test.tsx +++ b/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.test.tsx @@ -13,13 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import { RELATION_HAS_PART, RELATION_PART_OF } from '@backstage/catalog-model'; import { analyticsApiRef } from '@backstage/core-plugin-api'; -import { - CatalogApi, - catalogApiRef, - entityRouteRef, -} from '@backstage/plugin-catalog-react'; +import { catalogApiRef, entityRouteRef } from '@backstage/plugin-catalog-react'; import { MockAnalyticsApi, renderInTestApp, @@ -38,63 +35,59 @@ jest.mock('react-router', () => ({ describe('', () => { let wrapper: JSX.Element; - let catalog: jest.Mocked; + const entityC = { + apiVersion: 'a', + kind: 'b', + metadata: { + name: 'c', + namespace: 'd', + }, + relations: [ + { + type: RELATION_PART_OF, + targetRef: 'b:d/e', + target: { + kind: 'b', + namespace: 'd', + name: 'e', + }, + }, + ], + }; + const entityE = { + apiVersion: 'a', + kind: 'b', + metadata: { + name: 'e', + namespace: 'd', + }, + relations: [ + { + type: RELATION_HAS_PART, + targetRef: 'b:d/c', + target: { + kind: 'b', + namespace: 'd', + name: 'c', + }, + }, + ], + }; + const catalog = { + getEntities: jest.fn(), + getEntityByRef: jest.fn(), + removeEntityByUid: jest.fn(), + getLocationById: jest.fn(), + getLocationByRef: jest.fn(), + addLocation: jest.fn(), + removeLocationById: jest.fn(), + refreshEntity: jest.fn(), + getEntityAncestors: jest.fn(), + getEntityFacets: jest.fn(), + validateEntity: jest.fn(), + }; beforeEach(() => { - const entityC = { - apiVersion: 'a', - kind: 'b', - metadata: { - name: 'c', - namespace: 'd', - }, - relations: [ - { - type: RELATION_PART_OF, - targetRef: 'b:d/e', - target: { - kind: 'b', - namespace: 'd', - name: 'e', - }, - }, - ], - }; - const entityE = { - apiVersion: 'a', - kind: 'b', - metadata: { - name: 'e', - namespace: 'd', - }, - relations: [ - { - type: RELATION_HAS_PART, - targetRef: 'b:d/c', - target: { - kind: 'b', - namespace: 'd', - name: 'c', - }, - }, - ], - }; - catalog = { - getEntities: jest.fn(), - getEntityByRef: jest.fn(async (n: any) => - n === 'b:d/e' ? entityE : entityC, - ), - removeEntityByUid: jest.fn(), - getLocationById: jest.fn(), - getLocationByRef: jest.fn(), - addLocation: jest.fn(), - removeLocationById: jest.fn(), - refreshEntity: jest.fn(), - getEntityAncestors: jest.fn(), - getEntityFacets: jest.fn(), - validateEntity: jest.fn(), - }; - wrapper = ( ', () => { afterEach(() => jest.resetAllMocks()); test('should render without exploding', async () => { + catalog.getEntityByRef.mockImplementation(async (n: any) => + n === 'b:d/e' ? entityE : entityC, + ); + const { getByText, findByText, findAllByTestId } = await renderInTestApp( wrapper, { @@ -128,6 +125,10 @@ describe('', () => { }); test('should toggle filters', async () => { + catalog.getEntityByRef.mockImplementation(async (n: any) => + n === 'b:d/e' ? entityE : entityC, + ); + const { getByText, queryByText } = await renderInTestApp(wrapper, { mountedRoutes: { '/entity/{kind}/{namespace}/{name}': entityRouteRef, @@ -142,6 +143,10 @@ describe('', () => { }); test('should select other entity', async () => { + catalog.getEntityByRef.mockImplementation(async (n: any) => + n === 'b:d/e' ? entityE : entityC, + ); + const { getByText, findByText, findAllByTestId } = await renderInTestApp( wrapper, { @@ -159,6 +164,10 @@ describe('', () => { }); test('should navigate to entity', async () => { + catalog.getEntityByRef.mockImplementation(async (n: any) => + n === 'b:d/e' ? entityE : entityC, + ); + const { getByText, findAllByTestId } = await renderInTestApp(wrapper, { mountedRoutes: { '/entity/{kind}/{namespace}/{name}': entityRouteRef, @@ -174,6 +183,10 @@ describe('', () => { }); test('should capture analytics event when selecting other entity', async () => { + catalog.getEntityByRef.mockImplementation(async (n: any) => + n === 'b:d/e' ? entityE : entityC, + ); + const analyticsSpy = new MockAnalyticsApi(); const { getByText, findAllByTestId } = await renderInTestApp( @@ -200,6 +213,10 @@ describe('', () => { }); test('should capture analytics event when navigating to entity', async () => { + catalog.getEntityByRef.mockImplementation(async (n: any) => + n === 'b:d/e' ? entityE : entityC, + ); + const analyticsSpy = new MockAnalyticsApi(); const { getByText, findAllByTestId } = await renderInTestApp( diff --git a/plugins/catalog-graph/src/components/EntityRelationsGraph/EntityRelationsGraph.test.tsx b/plugins/catalog-graph/src/components/EntityRelationsGraph/EntityRelationsGraph.test.tsx index c79f975789..d7b9f9e3eb 100644 --- a/plugins/catalog-graph/src/components/EntityRelationsGraph/EntityRelationsGraph.test.tsx +++ b/plugins/catalog-graph/src/components/EntityRelationsGraph/EntityRelationsGraph.test.tsx @@ -22,7 +22,7 @@ import { RELATION_PART_OF, } from '@backstage/catalog-model'; import { DependencyGraphTypes } from '@backstage/core-components'; -import { CatalogApi, catalogApiRef } from '@backstage/plugin-catalog-react'; +import { catalogApiRef } from '@backstage/plugin-catalog-react'; import { renderInTestApp, TestApiProvider } from '@backstage/test-utils'; import userEvent from '@testing-library/user-event'; import React, { FunctionComponent } from 'react'; @@ -30,98 +30,96 @@ import { EntityRelationsGraph } from './EntityRelationsGraph'; describe('', () => { let Wrapper: FunctionComponent; - let catalog: jest.Mocked; + const entities: { [ref: string]: Entity } = { + 'b:d/c': { + apiVersion: 'a', + kind: 'b', + metadata: { + name: 'c', + namespace: 'd', + }, + relations: [ + { + targetRef: 'k:d/a1', + type: RELATION_OWNER_OF, + }, + { + targetRef: 'b:d/c1', + type: RELATION_HAS_PART, + }, + ], + }, + 'k:d/a1': { + apiVersion: 'a', + kind: 'k', + metadata: { + name: 'a1', + namespace: 'd', + }, + relations: [ + { + targetRef: 'b:d/c', + type: RELATION_OWNED_BY, + }, + { + targetRef: 'b:d/c1', + type: RELATION_OWNED_BY, + }, + ], + }, + 'b:d/c1': { + apiVersion: 'a', + kind: 'b', + metadata: { + name: 'c1', + namespace: 'd', + }, + relations: [ + { + targetRef: 'b:d/c', + type: RELATION_PART_OF, + }, + { + targetRef: 'k:d/a1', + type: RELATION_OWNER_OF, + }, + { + targetRef: 'b:d/c2', + type: RELATION_HAS_PART, + }, + ], + }, + 'b:d/c2': { + apiVersion: 'a', + kind: 'b', + metadata: { + name: 'c2', + namespace: 'd', + }, + relations: [ + { + targetRef: 'b:d/c1', + type: RELATION_PART_OF, + }, + ], + }, + }; + const catalog = { + getEntities: jest.fn(), + getEntityByRef: jest.fn(), + removeEntityByUid: jest.fn(), + getLocationById: jest.fn(), + getLocationByRef: jest.fn(), + addLocation: jest.fn(), + removeLocationById: jest.fn(), + refreshEntity: jest.fn(), + getEntityAncestors: jest.fn(), + getEntityFacets: jest.fn(), + validateEntity: jest.fn(), + }; const CUSTOM_TEST_ID = 'custom-test-id'; beforeEach(() => { - const entities: { [ref: string]: Entity } = { - 'b:d/c': { - apiVersion: 'a', - kind: 'b', - metadata: { - name: 'c', - namespace: 'd', - }, - relations: [ - { - targetRef: 'k:d/a1', - type: RELATION_OWNER_OF, - }, - { - targetRef: 'b:d/c1', - type: RELATION_HAS_PART, - }, - ], - }, - 'k:d/a1': { - apiVersion: 'a', - kind: 'k', - metadata: { - name: 'a1', - namespace: 'd', - }, - relations: [ - { - targetRef: 'b:d/c', - type: RELATION_OWNED_BY, - }, - { - targetRef: 'b:d/c1', - type: RELATION_OWNED_BY, - }, - ], - }, - 'b:d/c1': { - apiVersion: 'a', - kind: 'b', - metadata: { - name: 'c1', - namespace: 'd', - }, - relations: [ - { - targetRef: 'b:d/c', - type: RELATION_PART_OF, - }, - { - targetRef: 'k:d/a1', - type: RELATION_OWNER_OF, - }, - { - targetRef: 'b:d/c2', - type: RELATION_HAS_PART, - }, - ], - }, - 'b:d/c2': { - apiVersion: 'a', - kind: 'b', - metadata: { - name: 'c2', - namespace: 'd', - }, - relations: [ - { - targetRef: 'b:d/c1', - type: RELATION_PART_OF, - }, - ], - }, - }; - catalog = { - getEntities: jest.fn(), - getEntityByRef: jest.fn(async n => entities[n as string]), - removeEntityByUid: jest.fn(), - getLocationById: jest.fn(), - getLocationByRef: jest.fn(), - addLocation: jest.fn(), - removeLocationById: jest.fn(), - refreshEntity: jest.fn(), - getEntityAncestors: jest.fn(), - getEntityFacets: jest.fn(), - validateEntity: jest.fn(), - }; - Wrapper = ({ children }) => ( {children} @@ -129,7 +127,7 @@ describe('', () => { ); }); - afterAll(() => { + afterEach(() => { jest.resetAllMocks(); }); @@ -213,6 +211,8 @@ describe('', () => { }); test('renders at max depth of one', async () => { + catalog.getEntityByRef.mockImplementation(async n => entities[n as string]); + const { findByText, findAllByTestId, findAllByText } = await renderInTestApp( @@ -235,7 +235,9 @@ describe('', () => { expect(catalog.getEntityByRef).toHaveBeenCalledTimes(3); }); - test('renders simplied graph at full depth', async () => { + test('renders simplified graph at full depth', async () => { + catalog.getEntityByRef.mockImplementation(async n => entities[n as string]); + const { findByText, findAllByText, findAllByTestId } = await renderInTestApp( @@ -261,6 +263,8 @@ describe('', () => { }); test('renders full graph at full depth', async () => { + catalog.getEntityByRef.mockImplementation(async n => entities[n as string]); + const { findAllByText, findByText, findAllByTestId } = await renderInTestApp( @@ -288,6 +292,8 @@ describe('', () => { }); test('renders full graph at full depth with merged relations', async () => { + catalog.getEntityByRef.mockImplementation(async n => entities[n as string]); + const { findAllByText, findByText, findAllByTestId } = await renderInTestApp( @@ -313,6 +319,8 @@ describe('', () => { }); test('renders a graph with multiple root nodes', async () => { + catalog.getEntityByRef.mockImplementation(async n => entities[n as string]); + const { findAllByText, findByText, findAllByTestId } = await renderInTestApp( @@ -339,6 +347,8 @@ describe('', () => { }); test('renders a graph with filtered kinds and relations', async () => { + catalog.getEntityByRef.mockImplementation(async n => entities[n as string]); + const { findAllByText, findByText, findAllByTestId } = await renderInTestApp( @@ -361,6 +371,8 @@ describe('', () => { }); test('handle clicks on a node', async () => { + catalog.getEntityByRef.mockImplementation(async n => entities[n as string]); + const onNodeClick = jest.fn(); const { findByText } = await renderInTestApp( @@ -376,6 +388,8 @@ describe('', () => { }); test('render custom node', async () => { + catalog.getEntityByRef.mockImplementation(async n => entities[n as string]); + const renderNode = (props: DependencyGraphTypes.RenderNodeProps) => ( {props.node.id} @@ -398,6 +412,8 @@ describe('', () => { }); test('render custom label', async () => { + catalog.getEntityByRef.mockImplementation(async n => entities[n as string]); + const renderLabel = (props: DependencyGraphTypes.RenderLabelProps) => ( {`Test-Label${props.edge.label}`} diff --git a/plugins/catalog-graph/src/components/EntityRelationsGraph/useEntityStore.test.ts b/plugins/catalog-graph/src/components/EntityRelationsGraph/useEntityStore.test.ts index e76b1001c6..802f993802 100644 --- a/plugins/catalog-graph/src/components/EntityRelationsGraph/useEntityStore.test.ts +++ b/plugins/catalog-graph/src/components/EntityRelationsGraph/useEntityStore.test.ts @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import { Entity } from '@backstage/catalog-model'; import { useApi as useApiMocked } from '@backstage/core-plugin-api'; -import { CatalogApi } from '@backstage/plugin-catalog-react'; import { act, renderHook } from '@testing-library/react-hooks'; import { useEntityStore } from './useEntityStore'; @@ -24,23 +24,21 @@ jest.mock('@backstage/core-plugin-api'); const useApi = useApiMocked as jest.Mocked; describe('useEntityStore', () => { - let catalogApi: jest.Mocked; + const catalogApi = { + getEntities: jest.fn(), + getEntityByRef: jest.fn(), + removeEntityByUid: jest.fn(), + getLocationById: jest.fn(), + getLocationByRef: jest.fn(), + addLocation: jest.fn(), + removeLocationById: jest.fn(), + refreshEntity: jest.fn(), + getEntityAncestors: jest.fn(), + getEntityFacets: jest.fn(), + validateEntity: jest.fn(), + }; beforeEach(() => { - catalogApi = { - getEntities: jest.fn(), - getEntityByRef: jest.fn(), - removeEntityByUid: jest.fn(), - getLocationById: jest.fn(), - getLocationByRef: jest.fn(), - addLocation: jest.fn(), - removeLocationById: jest.fn(), - refreshEntity: jest.fn(), - getEntityAncestors: jest.fn(), - getEntityFacets: jest.fn(), - validateEntity: jest.fn(), - }; - useApi.mockReturnValue(catalogApi); }); diff --git a/plugins/catalog-import/src/api/CatalogImportClient.test.ts b/plugins/catalog-import/src/api/CatalogImportClient.test.ts index d507ac3bef..e77abc8a85 100644 --- a/plugins/catalog-import/src/api/CatalogImportClient.test.ts +++ b/plugins/catalog-import/src/api/CatalogImportClient.test.ts @@ -49,7 +49,7 @@ jest.mock('@octokit/rest', () => { import { ConfigReader, UrlPatternDiscovery } from '@backstage/core-app-api'; import { ScmIntegrations } from '@backstage/integration'; import { ScmAuthApi } from '@backstage/integration-react'; -import { catalogApiRef } from '@backstage/plugin-catalog-react'; +import { CatalogApi } from '@backstage/plugin-catalog-react'; import { setupRequestMockHandlers } from '@backstage/test-utils'; import { Octokit } from '@octokit/rest'; import { rest } from 'msw'; @@ -89,7 +89,7 @@ describe('CatalogImportClient', () => { }), ); - const catalogApi: jest.Mocked = { + const catalogApi = { getEntities: jest.fn(), addLocation: jest.fn(), removeLocationById: jest.fn(), @@ -111,7 +111,7 @@ describe('CatalogImportClient', () => { scmAuthApi, scmIntegrationsApi, identityApi, - catalogApi, + catalogApi: catalogApi as Partial as CatalogApi, configApi: new ConfigReader({ app: { baseUrl: 'https://demo.backstage.io/', @@ -458,7 +458,7 @@ describe('CatalogImportClient', () => { scmAuthApi, scmIntegrationsApi, identityApi, - catalogApi, + catalogApi: catalogApi as Partial as CatalogApi, configApi: new ConfigReader({ catalog: { import: { @@ -610,7 +610,7 @@ describe('CatalogImportClient', () => { scmAuthApi, scmIntegrationsApi, identityApi, - catalogApi, + catalogApi: catalogApi as Partial as CatalogApi, configApi: new ConfigReader({ catalog: { import: { @@ -680,7 +680,7 @@ describe('CatalogImportClient', () => { scmAuthApi, scmIntegrationsApi, identityApi, - catalogApi, + catalogApi: catalogApi as Partial as CatalogApi, configApi: new ConfigReader({ catalog: { import: { diff --git a/plugins/catalog-import/src/components/StepPrepareCreatePullRequest/StepPrepareCreatePullRequest.test.tsx b/plugins/catalog-import/src/components/StepPrepareCreatePullRequest/StepPrepareCreatePullRequest.test.tsx index 5ad7e27c4b..ae6225f912 100644 --- a/plugins/catalog-import/src/components/StepPrepareCreatePullRequest/StepPrepareCreatePullRequest.test.tsx +++ b/plugins/catalog-import/src/components/StepPrepareCreatePullRequest/StepPrepareCreatePullRequest.test.tsx @@ -35,7 +35,7 @@ describe('', () => { preparePullRequest: jest.fn(), }; - const catalogApi: jest.Mocked = { + const catalogApi = { getEntities: jest.fn(), addLocation: jest.fn(), getEntityByRef: jest.fn(), diff --git a/plugins/explore/src/components/DefaultExplorePage/DefaultExplorePage.test.tsx b/plugins/explore/src/components/DefaultExplorePage/DefaultExplorePage.test.tsx index 399112fac6..62d197803f 100644 --- a/plugins/explore/src/components/DefaultExplorePage/DefaultExplorePage.test.tsx +++ b/plugins/explore/src/components/DefaultExplorePage/DefaultExplorePage.test.tsx @@ -21,8 +21,8 @@ import React from 'react'; import { DefaultExplorePage } from './DefaultExplorePage'; describe('', () => { - const catalogApi: jest.Mocked = { - addLocation: jest.fn(_a => new Promise(() => {})), + const catalogApi = { + addLocation: jest.fn(), getEntities: jest.fn(), getLocationByRef: jest.fn(), getLocationById: jest.fn(), diff --git a/plugins/explore/src/components/DomainExplorerContent/DomainExplorerContent.test.tsx b/plugins/explore/src/components/DomainExplorerContent/DomainExplorerContent.test.tsx index c84363f5c6..a62083f66f 100644 --- a/plugins/explore/src/components/DomainExplorerContent/DomainExplorerContent.test.tsx +++ b/plugins/explore/src/components/DomainExplorerContent/DomainExplorerContent.test.tsx @@ -22,8 +22,8 @@ import React from 'react'; import { DomainExplorerContent } from './DomainExplorerContent'; describe('', () => { - const catalogApi: jest.Mocked = { - addLocation: jest.fn(_a => new Promise(() => {})), + const catalogApi = { + addLocation: jest.fn(), getEntities: jest.fn(), getLocationByRef: jest.fn(), getLocationById: jest.fn(), diff --git a/plugins/explore/src/components/GroupsExplorerContent/GroupsExplorerContent.test.tsx b/plugins/explore/src/components/GroupsExplorerContent/GroupsExplorerContent.test.tsx index a4769e8f4f..9b461fba7d 100644 --- a/plugins/explore/src/components/GroupsExplorerContent/GroupsExplorerContent.test.tsx +++ b/plugins/explore/src/components/GroupsExplorerContent/GroupsExplorerContent.test.tsx @@ -22,8 +22,8 @@ import React from 'react'; import { GroupsExplorerContent } from '../GroupsExplorerContent'; describe('', () => { - const catalogApi: jest.Mocked = { - addLocation: jest.fn(_a => new Promise(() => {})), + const catalogApi = { + addLocation: jest.fn(), getEntities: jest.fn(), getLocationByRef: jest.fn(), getLocationById: jest.fn(), diff --git a/plugins/fossa/src/components/FossaPage/FossaPage.test.tsx b/plugins/fossa/src/components/FossaPage/FossaPage.test.tsx index 676a3cff3c..be07b4707f 100644 --- a/plugins/fossa/src/components/FossaPage/FossaPage.test.tsx +++ b/plugins/fossa/src/components/FossaPage/FossaPage.test.tsx @@ -15,21 +15,16 @@ */ import { Entity } from '@backstage/catalog-model'; -import { - CatalogApi, - catalogApiRef, - entityRouteRef, -} from '@backstage/plugin-catalog-react'; +import { catalogApiRef, entityRouteRef } from '@backstage/plugin-catalog-react'; import { renderInTestApp, TestApiProvider } from '@backstage/test-utils'; import React from 'react'; import { FossaApi, fossaApiRef } from '../../api'; import { FossaPage } from './FossaPage'; describe('', () => { - const catalogApi: jest.Mocked = { + const catalogApi = { addLocation: jest.fn(), getEntities: jest.fn(), - getEntityByRef: jest.fn(), getLocationByRef: jest.fn(), getLocationById: jest.fn(), removeEntityByUid: jest.fn(), diff --git a/plugins/todo-backend/src/service/TodoReaderService.test.ts b/plugins/todo-backend/src/service/TodoReaderService.test.ts index 8077e2ddb9..3f68636a05 100644 --- a/plugins/todo-backend/src/service/TodoReaderService.test.ts +++ b/plugins/todo-backend/src/service/TodoReaderService.test.ts @@ -58,7 +58,7 @@ function mockCatalogClient(entity?: Entity): jest.Mocked { if (entity) { mock.getEntityByRef.mockReturnValue(entity); } - return mock; + return mock as Partial> as jest.Mocked; } function mockTodoReader(items?: TodoItem[]): jest.Mocked {