backend-app-api: fix for test not making root lifecycle service available

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2023-05-25 14:20:27 +02:00
parent 0a7e305fe2
commit be1379a4da
@@ -17,9 +17,11 @@
import {
createServiceRef,
createServiceFactory,
coreServices,
} from '@backstage/backend-plugin-api';
import { BackendInitializer } from './BackendInitializer';
import { ServiceRegistry } from './ServiceRegistry';
import { rootLifecycleServiceFactory } from '../services/implementations';
const rootRef = createServiceRef<{ x: number }>({
id: '1',
@@ -30,6 +32,16 @@ const pluginRef = createServiceRef<{ x: number }>({
id: '2',
});
class MockLogger {
debug() {}
info() {}
warn() {}
error() {}
child() {
return this;
}
}
describe('BackendInitializer', () => {
it('should initialize root scoped services', async () => {
const rootFactory = jest.fn();
@@ -46,6 +58,12 @@ describe('BackendInitializer', () => {
deps: {},
factory: pluginFactory,
})(),
rootLifecycleServiceFactory(),
createServiceFactory({
service: coreServices.rootLogger,
deps: {},
factory: () => new MockLogger(),
})(),
]);
const init = new BackendInitializer(registry);