|
1 | 1 | /** @prettier */
|
2 | 2 | import { expect } from 'chai';
|
3 |
| -import { forkJoin, of } from 'rxjs'; |
| 3 | +import { finalize, forkJoin, map, of, timer } from 'rxjs'; |
4 | 4 | import { lowerCaseO } from '../helpers/test-helper';
|
5 | 5 | import { TestScheduler } from 'rxjs/testing';
|
6 | 6 | import { observableMatcher } from '../helpers/observableMatcher';
|
@@ -303,6 +303,22 @@ describe('forkJoin', () => {
|
303 | 303 | });
|
304 | 304 | });
|
305 | 305 |
|
| 306 | + it('should finalize in the proper order', () => { |
| 307 | + const results: any[] = []; |
| 308 | + const source = forkJoin( |
| 309 | + [1, 2, 3, 4].map((n) => |
| 310 | + timer(100, rxTestScheduler).pipe( |
| 311 | + map(() => n), |
| 312 | + finalize(() => results.push(`finalized ${n}`)) |
| 313 | + ) |
| 314 | + ) |
| 315 | + ); |
| 316 | + |
| 317 | + source.subscribe((value) => results.push(value)); |
| 318 | + rxTestScheduler.flush(); |
| 319 | + expect(results).to.deep.equal(['finalized 1', 'finalized 2', 'finalized 3', 'finalized 4', [1, 2, 3, 4]]); |
| 320 | + }); |
| 321 | + |
306 | 322 | describe('forkJoin({ foo, bar, baz })', () => {
|
307 | 323 | it('should join the last values of the provided observables into an array', () => {
|
308 | 324 | rxTestScheduler.run(({ hot, expectObservable }) => {
|
|
0 commit comments