test(editor): Add test render helper to design system (#11064)
This commit is contained in:
20
packages/design-system/src/__tests__/render.ts
Normal file
20
packages/design-system/src/__tests__/render.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { render } from '@testing-library/vue';
|
||||
|
||||
import { N8nPlugin } from 'n8n-design-system/plugin';
|
||||
|
||||
type Component = Parameters<typeof render>[0];
|
||||
type RenderOptions = Parameters<typeof render>[1];
|
||||
|
||||
export const createComponentRenderer = (component: Component) => (options: RenderOptions) => {
|
||||
const mergedOptions: RenderOptions = {
|
||||
...options,
|
||||
global: {
|
||||
...(options?.global ?? {}),
|
||||
stubs: {
|
||||
...(options?.global?.stubs ?? {}),
|
||||
},
|
||||
plugins: [N8nPlugin, ...(options?.global?.plugins ?? [])],
|
||||
},
|
||||
};
|
||||
return render(component, mergedOptions);
|
||||
};
|
||||
@@ -4,3 +4,11 @@ import { config } from '@vue/test-utils';
|
||||
import { N8nPlugin } from 'n8n-design-system/plugin';
|
||||
|
||||
config.global.plugins = [N8nPlugin];
|
||||
|
||||
window.ResizeObserver =
|
||||
window.ResizeObserver ||
|
||||
vi.fn().mockImplementation(() => ({
|
||||
disconnect: vi.fn(),
|
||||
observe: vi.fn(),
|
||||
unobserve: vi.fn(),
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user