@@ -6,6 +6,7 @@ describe('createEffect()', () => {
66 code => `
77 import { Action } from '@ngrx/store';
88 import { createEffect } from '@ngrx/effects';
9+ import { createAction } from '@ngrx/store';
910 import { of } from 'rxjs';
1011
1112 ${ code } ` ,
@@ -21,7 +22,23 @@ describe('createEffect()', () => {
2122 expectSnippet ( `
2223 const effect = createEffect(() => of({ foo: 'a' }));
2324 ` ) . 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 /
2542 ) ;
2643 } ) ;
2744
@@ -33,7 +50,7 @@ describe('createEffect()', () => {
3350 expectSnippet ( `
3451 const effect = createEffect(() => of({ foo: 'a' }), { dispatch: true });
3552 ` ) . 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 > ' ./
3754 ) ;
3855 } ) ;
3956 } ) ;
@@ -47,8 +64,16 @@ describe('createEffect()', () => {
4764 expectSnippet ( `
4865 const effect = createEffect(() => ({ foo: 'a' }), { dispatch: false });
4966 ` ) . 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 > ' ./
5168 ) ;
5269 } ) ;
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+ } ) ;
5378 } ) ;
5479} ) ;
0 commit comments