From 2f23000c24c9212210885b50c5e4808ab4c4715b Mon Sep 17 00:00:00 2001 From: Nicholas Jamieson Date: Fri, 26 Apr 2019 18:13:27 +1000 Subject: [PATCH 1/3] test(endWith): add failing test --- spec/operators/endWith-spec.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spec/operators/endWith-spec.ts b/spec/operators/endWith-spec.ts index 0da37e53a5..f42d33bc65 100644 --- a/spec/operators/endWith-spec.ts +++ b/spec/operators/endWith-spec.ts @@ -20,6 +20,16 @@ describe('endWith operator', () => { expectSubscriptions(e1.subscriptions).toBe(e1subs); }); + it('should append numbers to a cold Observable', () => { + const values = { a: 1, b: 2, c: 3, s: 4 }; + const e1 = cold('---a--b--c--|', values); + const e1subs = '^ !'; + const expected = '---a--b--c--(s|)'; + + expectObservable(e1.pipe(endWith(values.s))).toBe(expected, values); + expectSubscriptions(e1.subscriptions).toBe(e1subs); + }); + it('should end an observable with given value', () => { const e1 = hot('--a--|'); const e1subs = '^ !'; From a831e7ae7518dfa21e45435c3a0f715d035dabf5 Mon Sep 17 00:00:00 2001 From: Nicholas Jamieson Date: Fri, 26 Apr 2019 18:15:42 +1000 Subject: [PATCH 2/3] fix(endWith): wrap args in of before concat --- src/internal/operators/endWith.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/internal/operators/endWith.ts b/src/internal/operators/endWith.ts index 2619192067..d5ed8a15ba 100644 --- a/src/internal/operators/endWith.ts +++ b/src/internal/operators/endWith.ts @@ -1,5 +1,6 @@ import { Observable } from '../Observable'; import { concat } from '../observable/concat'; +import { of } from '../observable/of'; import { MonoTypeOperatorFunction, SchedulerLike, OperatorFunction } from '../types'; /* tslint:disable:max-line-length */ @@ -62,5 +63,5 @@ export function endWith(...array: Array): OperatorF * @owner Observable */ export function endWith(...array: Array): MonoTypeOperatorFunction { - return (source: Observable) => concat(source, ...(array as any[])) as Observable; + return (source: Observable) => concat(source, of(...(array as any[]))) as Observable; } From 3d7f36eb8ae6be9148e723835cf6275b7927c5d0 Mon Sep 17 00:00:00 2001 From: Nicholas Jamieson Date: Thu, 2 May 2019 06:22:59 +1000 Subject: [PATCH 3/3] chore(endWith): remove any assertion --- src/internal/operators/endWith.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internal/operators/endWith.ts b/src/internal/operators/endWith.ts index d5ed8a15ba..46aa651e3f 100644 --- a/src/internal/operators/endWith.ts +++ b/src/internal/operators/endWith.ts @@ -63,5 +63,5 @@ export function endWith(...array: Array): OperatorF * @owner Observable */ export function endWith(...array: Array): MonoTypeOperatorFunction { - return (source: Observable) => concat(source, of(...(array as any[]))) as Observable; + return (source: Observable) => concat(source, of(...array)) as Observable; }