From e36fae2c2a6e9a213ccfb30fee7774d2f803e391 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 4 Sep 2023 14:59:28 +0200 Subject: [PATCH] frontend-plugin-api: initial createExtension test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fredrik Adelöw Co-authored-by: Johan Haals Co-authored-by: Camila Belo Co-authored-by: Philipp Hugenroth Signed-off-by: Patrik Oldsberg --- .../src/wiring/createExtension.test.ts | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 packages/frontend-plugin-api/src/wiring/createExtension.test.ts diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts new file mode 100644 index 0000000000..69ff83dfe9 --- /dev/null +++ b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts @@ -0,0 +1,47 @@ +/* + * Copyright 2023 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { createExtension } from './createExtension'; +import { createExtensionDataRef } from './createExtensionDataRef'; + +const stringData = createExtensionDataRef('string'); + +describe('createExtension', () => { + it('should create an extension with a simple output', () => { + const extension = createExtension({ + id: 'test', + at: 'root', + output: { + foo: coreExtensionData.title, + foo2: stringData, + }, + factory({ bind }) { + // Make it work well with required and optional output + // HOH - High Order Helper + bind({ + foo: 'bar', + }); + // @ts-expect-error + bind.foo(3); + // @ts-expect-error + bind.foo(); + // @ts-expect-error + bind.bar('bar'); + }, + }); + expect(extension.id).toBe('test'); + }); +});