-
Notifications
You must be signed in to change notification settings - Fork 71
/
ws-error.effect.spec.ts
50 lines (44 loc) · 1.47 KB
/
ws-error.effect.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { EventError } from '@marblejs/core';
import { Marbles } from '@marblejs/core/dist/+internal';
import { error$ } from '../ws-error.effect';
describe('error$', () => {
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('returns stream of error events for undefined error object', () => {
// given
const incomingEvent = { type: 'TEST_EVENT' };
const error = undefined;
const outgoingEvent = { type: incomingEvent.type, error: {} };
// then
Marbles.assertEffect(error$, [
['--a--', { a: incomingEvent }],
['--b--', { b: outgoingEvent }],
], { meta: { error } });
});
test('returns stream of error events for undefined event object', () => {
// given
const incomingEvent = undefined;
const error = undefined;
const outgoingEvent = { type: 'ERROR', error: {} };
// then
Marbles.assertEffect(error$, [
['--a--', { a: incomingEvent }],
['--b--', { b: outgoingEvent }],
], { meta: { error } });
});
});