Gist 159a8117261c02868bf3bb34f860ab9c
✓ Published0🌍 Public
Aackuser
Last edited Aug 9, 2017
Created on Jan 20, 2021
This example shows unit tests for an Angular `SampleService` that fetches airport data from a remote API. The service exposes two methods: `fetchAll$` returns a sorted list of airports, while `fetchByIATA$` retrieves a single airport by its IATA code. The tests use Angular’s `HttpClientTestingModule` and `HttpTestingController` to mock HTTP requests and flush dummy JSON data. The code verifies that the service correctly parses and orders the response, relying on RxJS observables and Angular’s dependency injection for testability.
AI-generated description