Skip to content

Commit

Permalink
test(fetch): test expectations after complete
Browse files Browse the repository at this point in the history
  • Loading branch information
cartant committed Apr 26, 2019
1 parent cd5895d commit 2597e0d
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions spec/observables/dom/fetch-spec.ts
Expand Up @@ -115,14 +115,19 @@ describe('fromFetch', () => {
expect(response).to.equal(OK_RESPONSE);
},
error: done,
complete: done,
complete: () => {
// Wait until the complete and the subsequent unsubscribe are finished
// before testing these expectations:
setTimeout(() => {
expect(MockAbortController.created).to.equal(1);
expect(mockFetch.calls.length).to.equal(1);
expect(mockFetch.calls[0].input).to.equal('/foo');
expect(mockFetch.calls[0].init.signal).not.to.be.undefined;
expect(mockFetch.calls[0].init.signal.aborted).to.be.false;
done();
}, 0);
}
});

expect(MockAbortController.created).to.equal(1);
expect(mockFetch.calls.length).to.equal(1);
expect(mockFetch.calls[0].input).to.equal('/foo');
expect(mockFetch.calls[0].init.signal).not.to.be.undefined;
expect(mockFetch.calls[0].init.signal.aborted).to.be.false;
});

it('should handle Response that is not `ok`', done => {
Expand Down

0 comments on commit 2597e0d

Please sign in to comment.