2024-01-16 07:18:34 -08:00
|
|
|
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>();
|
|
|
|
|
2024-01-31 06:34:22 -08:00
|
|
|
it('should update re-wrapped error level and message', () => {
|
2024-01-16 07:18:34 -08:00
|
|
|
const apiError = new NodeApiError(node, mock({ message: 'Some error happened', code: 500 }));
|
2024-01-31 06:34:22 -08:00
|
|
|
const opsError = new NodeOperationError(node, mock(), { message: 'Some operation failed' });
|
|
|
|
const wrapped1 = new NodeOperationError(node, apiError);
|
|
|
|
const wrapped2 = new NodeOperationError(node, opsError);
|
2024-01-16 07:18:34 -08:00
|
|
|
|
2024-01-31 06:34:22 -08:00
|
|
|
expect(wrapped1.level).toEqual('error');
|
|
|
|
expect(wrapped1.message).toEqual(
|
|
|
|
'[RE-WRAPPED]: The service was not able to process your request',
|
|
|
|
);
|
|
|
|
expect(wrapped2.level).toEqual('error');
|
|
|
|
expect(wrapped2.message).toEqual('[RE-WRAPPED]: Some operation failed');
|
2024-01-16 07:18:34 -08:00
|
|
|
});
|
|
|
|
});
|