@@ -82,6 +82,8 @@ export class AppModule {}
82
82
83
83
## @ngrx/effects
84
84
85
+ ### Registering Effects
86
+
85
87
BEFORE:
86
88
87
89
` app.module.ts `
@@ -125,6 +127,85 @@ export class AppModule { }
125
127
export class FeatureModule { }
126
128
```
127
129
130
+ ### Testing Effects
131
+
132
+ BEFORE:
133
+ ``` ts
134
+ import { EffectsTestingModule , EffectsRunner } from ' @ngrx/effects/testing' ;
135
+ import { MyEffects } from ' ./my-effects' ;
136
+
137
+ describe (' My Effects' , () => {
138
+ let effects: MyEffects ;
139
+ let runner: EffectsRunner ;
140
+ beforeEach (() => {
141
+ TestBed .configureTestingModule ({
142
+ imports: [
143
+ EffectsTestingModule
144
+ ],
145
+ providers: [
146
+ MyEffects ,
147
+ // other providers
148
+ ],
149
+ });
150
+
151
+ effects = TestBed .get (MyEffects );
152
+ runner = TestBed .get (EffectsRunner );
153
+ });
154
+
155
+ it (' should work' , () => {
156
+ runner .queue (SomeAction );
157
+
158
+ effects .someSource$ .subscribe (result => {
159
+ expect (result ).toBe (AnotherAction );
160
+ });
161
+ });
162
+ });
163
+ ```
164
+
165
+ AFTER:
166
+ ``` ts
167
+ import { TestBed } from ' @angular/core/testing' ;
168
+ import { provideMockActions } from ' @ngrx/effects/testing' ;
169
+ import { hot , cold } from ' jasmine-marbles' ;
170
+ import { MyEffects } from ' ./my-effects' ;
171
+ import { ReplaySubject } from ' rxjs/ReplaySubject' ;
172
+
173
+ describe (' My Effects' , () => {
174
+ let effects: MyEffects ;
175
+ let actions: Observable <any >;
176
+
177
+ beforeEach (() => {
178
+ TestBed .configureTestingModule ({
179
+ providers: [
180
+ MyEffects ,
181
+ provideMockActions (() => actions ),
182
+ // other providers
183
+ ],
184
+ });
185
+
186
+ effects = TestBed .get (MyEffects );
187
+ });
188
+
189
+ it (' should work' , () => {
190
+ actions = hot (' --a-' , { a: SomeAction , ... });
191
+
192
+ const expected = cold (' --b' , { b: AnotherAction });
193
+
194
+ expect (effects .someSource$ ).toBeObservable (expected );
195
+ });
196
+
197
+ it (' should work also' , () => {
198
+ actions = new ReplaySubject (1 );
199
+
200
+ actions .next (SomeAction );
201
+
202
+ effects .someSource$ .subscribe (result => {
203
+ expect (result ).toBe (AnotherAction );
204
+ });
205
+ });
206
+ });
207
+ ```
208
+
128
209
## @ngrx/router-store
129
210
130
211
BEFORE:
0 commit comments