diff --git a/packages/backend-common/src/index.ts b/packages/backend-common/src/index.ts index 4bc60f557f..b2c38ab506 100644 --- a/packages/backend-common/src/index.ts +++ b/packages/backend-common/src/index.ts @@ -17,4 +17,3 @@ export * from './errors'; export * from './logging'; export * from './middleware'; -export * from './testing'; diff --git a/packages/backend-common/src/testing/MockedMemberFunctions.ts b/packages/backend-common/src/testing/MockedMemberFunctions.ts deleted file mode 100644 index 9b35908bff..0000000000 --- a/packages/backend-common/src/testing/MockedMemberFunctions.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * For any type T, generate a new type that is identical but also has the - * jest.fn signature on all member functions. - * - * When writing tests against a type, you sometimes end up in a situation where - * you need to write expect(x.y as jest.Mock).toHaveBeenCalled... because the - * x.y member was considered to be the actual function type. You could also - * change your test to instead create a "raw" object { y: jest.fn() } but then - * you lose type safety when doing x.y.mockReturnValue(...). So you start - * trying to do { y: jest.fn() as X['y'] } as X or similar trickery. - * - * This type lets you say const x: MockedMemberFunctions = { y: jest.fn() } - * and keep all the type safety at every step. - */ -export type MockedMemberFunctions = { - [K in keyof T]: T[K] extends (...args: infer A) => infer B - ? T[K] & jest.Mock - : T[K]; -}; diff --git a/packages/backend-common/src/testing/index.ts b/packages/backend-common/src/testing/index.ts deleted file mode 100644 index c12297465b..0000000000 --- a/packages/backend-common/src/testing/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export type { MockedMemberFunctions } from './MockedMemberFunctions'; diff --git a/plugins/catalog-backend/src/catalog/DatabaseEntitiesCatalog.test.ts b/plugins/catalog-backend/src/catalog/DatabaseEntitiesCatalog.test.ts index c5101dff7a..1de5038112 100644 --- a/plugins/catalog-backend/src/catalog/DatabaseEntitiesCatalog.test.ts +++ b/plugins/catalog-backend/src/catalog/DatabaseEntitiesCatalog.test.ts @@ -14,13 +14,12 @@ * limitations under the License. */ -import type { MockedMemberFunctions } from '@backstage/backend-common'; import type { Entity, EntityPolicy } from '@backstage/catalog-model'; import type { Database } from '../database'; import { DatabaseEntitiesCatalog } from './DatabaseEntitiesCatalog'; describe('DatabaseEntitiesCatalog', () => { - let db: MockedMemberFunctions; + let db: jest.Mocked; let policy: EntityPolicy; beforeEach(() => {