chore: added test for dataRef exporting

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2024-07-22 16:10:05 +02:00
parent 7777b5fb40
commit cf9da6dafb
@@ -18,6 +18,7 @@ import React from 'react';
import { coreExtensionData } from './coreExtensionData';
import { createExtensionBlueprint } from './createExtensionBlueprint';
import { createExtensionTester } from '@backstage/frontend-test-utils';
import { createExtensionDataRef } from './createExtensionDataRef';
describe('createExtensionBlueprint', () => {
it('should allow creation of extension blueprints', () => {
@@ -102,4 +103,28 @@ describe('createExtensionBlueprint', () => {
const { container } = createExtensionTester(extension).render();
expect(container.querySelector('h2')).toHaveTextContent('Hello, world!');
});
it('should allow exporting the dataRefs from the extension blueprint', () => {
const dataRef = createExtensionDataRef<string>().with({ id: 'test.data' });
const TestExtensionBlueprint = createExtensionBlueprint({
kind: 'test-extension',
attachTo: { id: 'test', input: 'default' },
output: {
element: coreExtensionData.reactElement,
},
dataRefs: {
data: dataRef,
},
factory(params: { text: string }) {
return {
element: <h1>{params.text}</h1>,
};
},
});
expect(TestExtensionBlueprint.dataRefs).toEqual({
data: dataRef,
});
});
});