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', ...

Get Mastering TypeScript 3 - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.