Skip to content

Commit 986be2f

Browse files
cartantbenlesh
authored andcommitted
fix(endWith): wrap args - they are not observables - in of before concatenating (#4735)
* test(endWith): add failing test * fix(endWith): wrap args in of before concat * chore(endWith): remove any assertion
1 parent 7926122 commit 986be2f

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎spec/operators/endWith-spec.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ describe('endWith operator', () => {
2020
expectSubscriptions(e1.subscriptions).toBe(e1subs);
2121
});
2222

23+
it('should append numbers to a cold Observable',()=>{
24+
constvalues={a: 1,b: 2,c: 3,s: 4};
25+
conste1=cold('---a--b--c--|',values);
26+
conste1subs='^ !';
27+
constexpected='---a--b--c--(s|)';
28+
29+
expectObservable(e1.pipe(endWith(values.s))).toBe(expected,values);
30+
expectSubscriptions(e1.subscriptions).toBe(e1subs);
31+
});
32+
2333
it('should end an observable with given value',()=>{
2434
conste1=hot('--a--|');
2535
conste1subs='^ !';

‎src/internal/operators/endWith.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import{Observable}from'../Observable';
22
import{concat}from'../observable/concat';
3+
import{of}from'../observable/of';
34
import{MonoTypeOperatorFunction,SchedulerLike,OperatorFunction}from'../types';
45

56
/* tslint:disable:max-line-length */
@@ -62,5 +63,5 @@ export function endWith<T, Z = T>(...array: Array<Z | SchedulerLike>): OperatorF
6263
* @owner Observable
6364
*/
6465
exportfunctionendWith<T>(...array: Array<T|SchedulerLike>): MonoTypeOperatorFunction<T>{
65-
return(source: Observable<T>)=>concat(source, ...(arrayasany[]))asObservable<T>;
66+
return(source: Observable<T>)=>concat(source,of(...array))asObservable<T>;
6667
}

0 commit comments

Comments
 (0)