@@ -6,6 +6,7 @@ describe('createEffect()', () => {
6
6
code => `
7
7
import { Action } from '@ngrx/store';
8
8
import { createEffect } from '@ngrx/effects';
9
+ import { createAction } from '@ngrx/store';
9
10
import { of } from 'rxjs';
10
11
11
12
${ code } ` ,
@@ -21,7 +22,23 @@ describe('createEffect()', () => {
21
22
expectSnippet ( `
22
23
const effect = createEffect(() => of({ foo: 'a' }));
23
24
` ) . toFail (
24
- / T y p e ' O b s e r v a b l e < { f o o : s t r i n g ; } > ' i s n o t a s s i g n a b l e t o t y p e ' O b s e r v a b l e < A c t i o n > | ( ( ...a r g s : a n y [ ] ) = > O b s e r v a b l e < A c t i o n > ) ' ./
25
+ / T y p e ' O b s e r v a b l e < { f o o : s t r i n g ; } > ' i s n o t a s s i g n a b l e t o t y p e ' E f f e c t R e s u l t < A c t i o n > ' ./
26
+ ) ;
27
+ } ) ;
28
+
29
+ it ( 'should help with action creator that is not called' , ( ) => {
30
+ // Action creator is called with parentheses.
31
+ expectSnippet ( `
32
+ const action = createAction('action without props');
33
+ const effect = createEffect(() => of(action()));
34
+ ` ) . toSucceed ( ) ;
35
+
36
+ // Action creator is not called (no parentheses).
37
+ expectSnippet ( `
38
+ const action = createAction('action without props');
39
+ const effect = createEffect(() => of(action));
40
+ ` ) . toFail (
41
+ / A c t i o n C r e a t o r c a n n o t b e d i s p a t c h e d . D i d y o u f o r g e t t o c a l l t h e a c t i o n c r e a t o r f u n c t i o n /
25
42
) ;
26
43
} ) ;
27
44
@@ -33,7 +50,7 @@ describe('createEffect()', () => {
33
50
expectSnippet ( `
34
51
const effect = createEffect(() => of({ foo: 'a' }), { dispatch: true });
35
52
` ) . toFail (
36
- / T y p e ' O b s e r v a b l e < { f o o : s t r i n g ; } > ' i s n o t a s s i g n a b l e t o t y p e ' O b s e r v a b l e < A c t i o n > | ( ( ... a r g s : a n y [ ] ) = > O b s e r v a b l e < A c t i o n > ) ' ./
53
+ / T y p e ' O b s e r v a b l e < { f o o : s t r i n g ; } > ' i s n o t a s s i g n a b l e t o t y p e ' E f f e c t R e s u l t < A c t i o n > ' ./
37
54
) ;
38
55
} ) ;
39
56
} ) ;
@@ -47,8 +64,16 @@ describe('createEffect()', () => {
47
64
expectSnippet ( `
48
65
const effect = createEffect(() => ({ foo: 'a' }), { dispatch: false });
49
66
` ) . toFail (
50
- / T y p e ' { f o o : s t r i n g ; } ' i s n o t a s s i g n a b l e t o t y p e ' O b s e r v a b l e < u n k n o w n > | ( ( ... a r g s : a n y [ ] ) = > O b s e r v a b l e < u n k n o w n > ) ' ./
67
+ / T y p e ' { f o o : s t r i n g ; } ' i s n o t a s s i g n a b l e t o t y p e ' E f f e c t R e s u l t < u n k n o w n > ' ./
51
68
) ;
52
69
} ) ;
70
+
71
+ it ( 'should allow action creator even if it is not called' , ( ) => {
72
+ // Action creator is not called (no parentheses), but we have no-dispatch.
73
+ expectSnippet ( `
74
+ const action = createAction('action without props');
75
+ const effect = createEffect(() => of(action), { dispatch: false });
76
+ ` ) . toSucceed ( ) ;
77
+ } ) ;
53
78
} ) ;
54
79
} ) ;
0 commit comments