add unit tests

This commit is contained in:
Mutasem Aldmour 2024-11-14 14:10:47 +01:00
parent 47e80f70a6
commit 8e2a562220
No known key found for this signature in database
GPG key ID: 3DFA8122BB7FD6B8

View file

@ -3,6 +3,17 @@ import type { ExecutionSummary } from 'n8n-workflow';
import { i18n } from '@/plugins/i18n'; import { i18n } from '@/plugins/i18n';
import { convertToDisplayDate } from '@/utils/formatters/dateFormatter'; import { convertToDisplayDate } from '@/utils/formatters/dateFormatter';
const { resolve } = vi.hoisted(() => ({
resolve: vi.fn(),
}));
vi.mock('vue-router', () => ({
useRouter: () => ({
resolve,
}),
RouterLink: vi.fn(),
}));
describe('useExecutionHelpers()', () => { describe('useExecutionHelpers()', () => {
describe('getUIDetails()', () => { describe('getUIDetails()', () => {
it.each([ it.each([
@ -68,4 +79,18 @@ describe('useExecutionHelpers()', () => {
).toEqual(false); ).toEqual(false);
}); });
}); });
describe('openExecutionInNewTab', () => {
const executionId = '123';
const workflowId = 'xyz';
const href = 'test.com';
global.window.open = vi.fn();
it('opens execution in new tab', () => {
const { openExecutionInNewTab } = useExecutionHelpers();
resolve.mockReturnValue({ href });
openExecutionInNewTab(executionId, workflowId);
expect(window.open).toHaveBeenCalledWith(href, '_blank');
});
});
}); });