chore: update backend tests

Co-authored-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Fredrik Adelöw <freben@gmail.com>
Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
Johan Haals
2022-08-12 16:09:17 +02:00
parent b76eeaf302
commit 91dd47a6a1
@@ -16,16 +16,25 @@
import {
createBackendModule,
createExtensionPoint,
createServiceFactory,
createServiceRef,
} from '@backstage/backend-plugin-api';
import { startTestBackend } from './TestBackend';
describe('TestBackend', () => {
it('should get a type error if service implementation does not match', () => {
const serviceRef = createServiceRef<{ a: string; b: string }>({ id: 'a' });
const backend = startTestBackend({
it('should get a type error if service implementation does not match', async () => {
type Obj = { a: string; b: string };
const serviceRef = createServiceRef<Obj>({ id: 'a' });
const extensionPoint1 = createExtensionPoint<Obj>({ id: 'b1' });
const extensionPoint2 = createExtensionPoint<Obj>({ id: 'b2' });
const extensionPoint3 = createExtensionPoint<Obj>({ id: 'b3' });
const extensionPoint4 = createExtensionPoint<Obj>({ id: 'b4' });
const extensionPoint5 = createExtensionPoint<Obj>({ id: 'b5' });
await startTestBackend({
services: [
// @ts-expect-error
[extensionPoint1, { a: 'a' }],
[serviceRef, { a: 'a' }],
[serviceRef, { a: 'a', b: 'b' }],
// @ts-expect-error
@@ -35,8 +44,20 @@ describe('TestBackend', () => {
// @ts-expect-error
[serviceRef, { a: 'a', b: 'b', c: 'c' }],
],
extensionPoints: [
// @ts-expect-error
[serviceRef, { a: 'a' }],
[extensionPoint1, { a: 'a' }],
[extensionPoint2, { a: 'a', b: 'b' }],
// @ts-expect-error
[extensionPoint3, { c: 'c' }],
// @ts-expect-error
[extensionPoint4, { a: 'a', c: 'c' }],
// @ts-expect-error
[extensionPoint5, { a: 'a', b: 'b', c: 'c' }],
],
});
expect(backend).toBeDefined();
expect(1).toBe(1);
});
it('should start the test backend', async () => {