1 | (function (global, factory) {
|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@ngrx/effects'), require('rxjs')) :
|
3 | typeof define === 'function' && define.amd ? define('@ngrx/effects/testing', ['exports', '@ngrx/effects', 'rxjs'], factory) :
|
4 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ngrx = global.ngrx || {}, global.ngrx.effects = global.ngrx.effects || {}, global.ngrx.effects.testing = {}), global.ngrx.effects, global.rxjs));
|
5 | }(this, (function (exports, effects, rxjs) { 'use strict';
|
6 |
|
7 | /**
|
8 | * @description
|
9 | * Creates mock actions provider.
|
10 | *
|
11 | * @param factoryOrSource Actions' source or source creation function
|
12 | *
|
13 | * @usageNotes
|
14 | *
|
15 | * **With `TestBed.configureTestingModule`**
|
16 | *
|
17 | * ```ts
|
18 | * describe('Books Effects', () => {
|
19 | * let actions$: Observable<any>;
|
20 | * let effects: BooksEffects;
|
21 | *
|
22 | * beforeEach(() => {
|
23 | * TestBed.configureTestingModule({
|
24 | * providers: [
|
25 | * provideMockActions(() => actions$),
|
26 | * BooksEffects,
|
27 | * ],
|
28 | * });
|
29 | *
|
30 | * actions$ = TestBed.inject(Actions);
|
31 | * effects = TestBed.inject(BooksEffects);
|
32 | * });
|
33 | * });
|
34 | * ```
|
35 | *
|
36 | * **With `Injector.create`**
|
37 | *
|
38 | * ```ts
|
39 | * describe('Counter Effects', () => {
|
40 | * let injector: Injector;
|
41 | * let actions$: Observable<any>;
|
42 | * let effects: CounterEffects;
|
43 | *
|
44 | * beforeEach(() => {
|
45 | * injector = Injector.create({
|
46 | * providers: [
|
47 | * provideMockActions(() => actions$),
|
48 | * CounterEffects,
|
49 | * ],
|
50 | * });
|
51 | *
|
52 | * actions$ = injector.get(Actions);
|
53 | * effects = injector.get(CounterEffects);
|
54 | * });
|
55 | * });
|
56 | * ```
|
57 | */
|
58 | function provideMockActions(factoryOrSource) {
|
59 | return {
|
60 | provide: effects.Actions,
|
61 | useFactory: function () {
|
62 | if (typeof factoryOrSource === 'function') {
|
63 | return new effects.Actions(rxjs.defer(factoryOrSource));
|
64 | }
|
65 | return new effects.Actions(factoryOrSource);
|
66 | },
|
67 | deps: [],
|
68 | };
|
69 | }
|
70 |
|
71 | /**
|
72 | * Generated bundle index. Do not edit.
|
73 | */
|
74 |
|
75 | exports.provideMockActions = provideMockActions;
|
76 |
|
77 | Object.defineProperty(exports, '__esModule', { value: true });
|
78 |
|
79 | })));
|
80 | //# sourceMappingURL=ngrx-effects-testing.umd.js.map
|