backend-test-utils: update ServiceFactoryTester to not accept callback form
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/backend-test-utils': patch
|
||||
---
|
||||
|
||||
Updated `ServiceFactoryTester` to only accept plain service factory objects, no longer supporting the callback form. This lines up with the changes to `@backstage/backend-plugin-api` and should not require any code changes.
|
||||
@@ -371,9 +371,7 @@ export namespace mockServices {
|
||||
// @public
|
||||
export class ServiceFactoryTester<TService, TScope extends 'root' | 'plugin'> {
|
||||
static from<TService, TScope extends 'root' | 'plugin'>(
|
||||
subject:
|
||||
| ServiceFactory<TService, TScope>
|
||||
| (() => ServiceFactory<TService, TScope>),
|
||||
subject: ServiceFactory<TService, TScope>,
|
||||
options?: ServiceFactoryTesterOptions,
|
||||
): ServiceFactoryTester<TService, TScope>;
|
||||
get(
|
||||
@@ -387,7 +385,7 @@ export class ServiceFactoryTester<TService, TScope extends 'root' | 'plugin'> {
|
||||
|
||||
// @public
|
||||
export interface ServiceFactoryTesterOptions {
|
||||
dependencies?: Array<ServiceFactory | (() => ServiceFactory)>;
|
||||
dependencies?: Array<ServiceFactory>;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
|
||||
@@ -35,7 +35,7 @@ export interface ServiceFactoryTesterOptions {
|
||||
* If a service factory is provided for a service that already has a default
|
||||
* implementation, the provided factory will override the default.
|
||||
*/
|
||||
dependencies?: Array<ServiceFactory | (() => ServiceFactory)>;
|
||||
dependencies?: Array<ServiceFactory>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,20 +55,15 @@ export class ServiceFactoryTester<TService, TScope extends 'root' | 'plugin'> {
|
||||
* @returns A new tester instance for the provided subject.
|
||||
*/
|
||||
static from<TService, TScope extends 'root' | 'plugin'>(
|
||||
subject:
|
||||
| ServiceFactory<TService, TScope>
|
||||
| (() => ServiceFactory<TService, TScope>),
|
||||
subject: ServiceFactory<TService, TScope>,
|
||||
options?: ServiceFactoryTesterOptions,
|
||||
) {
|
||||
const subjectFactory = typeof subject === 'function' ? subject() : subject;
|
||||
const registry = ServiceRegistry.create([
|
||||
...defaultServiceFactories,
|
||||
...(options?.dependencies?.map(f =>
|
||||
typeof f === 'function' ? f() : f,
|
||||
) ?? []),
|
||||
subjectFactory,
|
||||
...(options?.dependencies ?? []),
|
||||
subject,
|
||||
]);
|
||||
return new ServiceFactoryTester(subjectFactory.service, registry);
|
||||
return new ServiceFactoryTester(subject.service, registry);
|
||||
}
|
||||
|
||||
private constructor(
|
||||
|
||||
Reference in New Issue
Block a user