Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('handles error if error$ is defined', () => {
// given
const client = { sendResponse: jest.fn() } as any as MarbleWebSocketClient;
const error = new EventError({ type: 'EVENT' }, '');
const error$: WsErrorEffect = event$ => event$.pipe(
mapTo({ type: error.event.type, error: {} }),
);
// when
handleEffectsError(defaultMetadata, client, error$)(error);
// then
expect(client.sendResponse).toHaveBeenCalled();
});
test('returns stream of error events for defined error object', () => {
// given
const incomingEvent = { type: 'TEST_EVENT' };
const error = new EventError(incomingEvent, 'Test error message', { errorData: 'test_error_data' });
const outgoingEvent = {
type: incomingEvent.type,
error: {
message: error.message,
data: error.data,
},
};
// then
Marbles.assertEffect(error$, [
['--a--', { a: incomingEvent }],
['--b--', { b: outgoingEvent }],
], { meta: { error } });
});
test('does nothing if error$ is undefined', () => {
// given
const client = { sendResponse: jest.fn() } as any as MarbleWebSocketClient;
const error = new EventError({ type: 'EVENT' }, '');
// when
handleEffectsError(defaultMetadata, client, undefined)(error);
// then
expect(client.sendResponse).not.toHaveBeenCalled();
});
});
mergeMap(event => throwError(new EventError(event, 'test message'))),
);
catchError((error: IOError) => throwError(
new EventError(event as any, error.message, error.data),
)),
)),