@@ -171,6 +171,7 @@ describe('EffectSources', () => {
171
171
this . effectIdentifier = identifier ;
172
172
}
173
173
}
174
+
174
175
class SourceWithInitAction implements OnInitEffects , OnIdentifyEffects {
175
176
effectIdentifier : string ;
176
177
@@ -207,6 +208,17 @@ describe('EffectSources', () => {
207
208
const recordB = {
208
209
b : createEffect ( ( ) => alwaysOf ( b ) , { functional : true } ) ,
209
210
} ;
211
+ // a record with functional effects that is defined as
212
+ // a named import in a built package doesn't have a prototype
213
+ // for more info see: https://github.com/ngrx/platform/issues/3972
214
+ const recordC = Object . freeze ( {
215
+ __proto__ : null ,
216
+ c : createEffect ( ( ) => alwaysOf ( c ) , { functional : true } ) ,
217
+ } ) ;
218
+ const recordD = Object . freeze ( {
219
+ __proto__ : null ,
220
+ d : createEffect ( ( ) => alwaysOf ( d as any ) , { functional : true } ) ,
221
+ } ) ;
210
222
211
223
it ( 'should resolve effects from class instances' , ( ) => {
212
224
const sources$ = cold ( '--a--b--' , {
@@ -221,8 +233,12 @@ describe('EffectSources', () => {
221
233
} ) ;
222
234
223
235
it ( 'should resolve effects from records' , ( ) => {
224
- const sources$ = cold ( '--a--b--' , { a : recordA , b : recordB } ) ;
225
- const expected = cold ( '--a--b--' , { a, b } ) ;
236
+ const sources$ = cold ( '--a--b--c--' , {
237
+ a : recordA ,
238
+ b : recordB ,
239
+ c : recordC ,
240
+ } ) ;
241
+ const expected = cold ( '--a--b--c--' , { a, b, c } ) ;
226
242
227
243
const output = toActions ( sources$ ) ;
228
244
@@ -338,7 +354,7 @@ describe('EffectSources', () => {
338
354
expect ( output ) . toBeObservable ( expected ) ;
339
355
} ) ;
340
356
341
- it ( 'should report an error if an effect dispatches an invalid action' , ( ) => {
357
+ it ( 'should report an error if a class-based effect dispatches an invalid action' , ( ) => {
342
358
const sources$ = of ( new SourceD ( ) ) ;
343
359
344
360
toActions ( sources$ ) . subscribe ( ) ;
@@ -350,6 +366,18 @@ describe('EffectSources', () => {
350
366
) ;
351
367
} ) ;
352
368
369
+ it ( 'should report an error if a functional effect dispatches an invalid action' , ( ) => {
370
+ const sources$ = of ( recordD ) ;
371
+
372
+ toActions ( sources$ ) . subscribe ( ) ;
373
+
374
+ expect ( mockErrorReporter . handleError ) . toHaveBeenCalledWith (
375
+ new Error (
376
+ 'Effect "d()" dispatched an invalid action: {"not":"a valid action"}'
377
+ )
378
+ ) ;
379
+ } ) ;
380
+
353
381
it ( 'should report an error if an effect dispatches an `undefined`' , ( ) => {
354
382
const sources$ = of ( new SourceE ( ) ) ;
355
383
0 commit comments