update tests to be more robust against catalog-client changes

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-11-14 16:50:17 +01:00
parent 68360a5fc6
commit 9bafcfc209
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,
});