Merge pull request #14618 from backstage/freben/catalog-client-tests

update tests to be more robust against catalog-client changes
This commit is contained in:
Fredrik Adelöw
2022-11-15 14:35:46 +01:00
committed by GitHub
13 changed files with 269 additions and 224 deletions
@@ -29,7 +29,19 @@ import { BadgeBuilder } from '../lib';
describe('createRouter', () => {
let app: express.Express;
let badgeBuilder: jest.Mocked<BadgeBuilder>;
let catalog: jest.Mocked<CatalogApi>;
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<CatalogApi> as CatalogApi,
config,
discovery,
});
@@ -95,7 +93,7 @@ describe('createRouter', () => {
it('works', async () => {
const router = await createRouter({
badgeBuilder,
catalog,
catalog: catalog as Partial<CatalogApi> as CatalogApi,
config,
discovery,
});