From 55fbe58d3367182160df8c8083333dd313fd3137 Mon Sep 17 00:00:00 2001 From: Nicholas Jamieson Date: Wed, 15 Jan 2020 13:27:21 +1000 Subject: [PATCH] test: add failing test for #5233 --- spec/observables/dom/fetch-spec.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spec/observables/dom/fetch-spec.ts b/spec/observables/dom/fetch-spec.ts index b8346a4f39..da9e6bb4d2 100644 --- a/spec/observables/dom/fetch-spec.ts +++ b/spec/observables/dom/fetch-spec.ts @@ -176,6 +176,25 @@ describe('fromFetch', () => { expect(mockFetch.calls[0].init.signal.aborted).to.be.true; }); + it('should not immediately abort repeat subscribers', () => { + const fetch$ = fromFetch('/foo'); + expect(mockFetch.calls.length).to.equal(0); + expect(MockAbortController.created).to.equal(0); + let subscription = fetch$.subscribe(); + expect(MockAbortController.created).to.equal(1); + expect(mockFetch.calls[0].init.signal.aborted).to.be.false; + + subscription.unsubscribe(); + expect(mockFetch.calls[0].init.signal.aborted).to.be.true; + + subscription = fetch$.subscribe(); + expect(MockAbortController.created).to.equal(2); + expect(mockFetch.calls[1].init.signal.aborted).to.be.false; + + subscription.unsubscribe(); + expect(mockFetch.calls[1].init.signal.aborted).to.be.true; + }); + it('should allow passing of init object', done => { const fetch$ = fromFetch('/foo', {method: 'HEAD'}); fetch$.subscribe({