Skip to Main Content
Mastering TypeScript 3 - Third Edition
book

Mastering TypeScript 3 - Third Edition

by Nathan Rozentals
February 2019
Beginner content levelBeginner
694 pages
18h 4m
English
Packt Publishing
Content preview from Mastering TypeScript 3 - Third Edition

Unit-testing Observables

Before we continue with our application, let's take a quick look at how we can unit-test our BoardListComponent, and, in particular, its use of Observables. The BoardListComponent class uses the BoardService in order to load information from three different REST Endpoints. It calls the getBoardList, getBoardSizes, and getBoardTypes functions of the BoardService. It also coordinates these calls using concatMap and forkJoin. Each of the calls to the BoardService return Observables. Fortunately, mocking Observables within a unit test is relatively simple. Let's update the board-list.component.spec.ts file that was automatically generated using the Angular CLI, as follows:

describe('/src/app/board-list/board-list.component.spec.ts', ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The TypeScript Workshop

The TypeScript Workshop

Ben Grynhaus, Jordan Hudgens, Rayon Hunte, Matt Morgan, Wekoslav Stefanovski

Publisher Resources

ISBN: 9781789536706Supplemental Content