mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 12:57:29 -08:00
test(editor): Add test render helper to design system (#11064)
This commit is contained in:
parent
12e54a5eea
commit
835824cf53
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(),
|
||||
}));
|
||||
|
|
Loading…
Reference in a new issue