test(editor): Add test render helper to design system (#11064)

This commit is contained in:
Csaba Tuncsik 2024-10-03 09:28:40 +02:00 committed by GitHub
parent 12e54a5eea
commit 835824cf53
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 0 deletions

View 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);
};

View file

@ -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(),
}));