mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-14 08:34:07 -08:00
5301323906
Co-authored-by: Michael Kret <michael.k@radency.com>
23 lines
1 KiB
TypeScript
23 lines
1 KiB
TypeScript
import { mock } from 'jest-mock-extended';
|
|
import type { INode } from '@/Interfaces';
|
|
import { NodeApiError } from '@/errors/node-api.error';
|
|
import { NodeOperationError } from '@/errors/node-operation.error';
|
|
|
|
describe('NodeError', () => {
|
|
const node = mock<INode>();
|
|
|
|
it('should update re-wrapped error level and message', () => {
|
|
const apiError = new NodeApiError(node, { message: 'Some error happened', code: 500 });
|
|
const opsError = new NodeOperationError(node, mock(), { message: 'Some operation failed' });
|
|
const wrapped1 = new NodeOperationError(node, apiError);
|
|
const wrapped2 = new NodeOperationError(node, opsError);
|
|
|
|
expect(wrapped1.level).toEqual('error');
|
|
expect(wrapped1.message).toEqual('The service was not able to process your request');
|
|
expect(wrapped1.tags).toEqual(expect.objectContaining({ reWrapped: true }));
|
|
expect(wrapped2.level).toEqual('error');
|
|
expect(wrapped2.message).toEqual('Some operation failed');
|
|
expect(wrapped2.tags).toEqual(expect.objectContaining({ reWrapped: true }));
|
|
});
|
|
});
|