Writing a Real-world Test
Get familiar with writing a real-world test.
We'll cover the following...
There’s no better way to understand how to bend time using virtual time than to write a test for a time-sensitive task in the real world. Let’s recover an Observable from the earthquake viewer we made earlier.
To make the code more testable, let’s encapsulate the Observable in a function that takes a Scheduler we use in the bufferWithTime operator. It’s always a good idea to parameterize Schedulers in Observables that will be tested.
Let’s also simplify the code by taking some steps out, but retaining the essence of it. This code takes an Observable of JSON objects that contain a properties property, buffers them into batches released every 500 milliseconds, and filters the batches that arrive empty.
We want to verify that this code works, but ...