From the course: Building Angular and Django Apps

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Unit testing a service

Unit testing a service

From the course: Building Angular and Django Apps

Start my 1-month free trial

Unit testing a service

- [Instructor] Now we're going to be testing on Angular service, the rest API service. We begin by creating it here, and before every test, we're going to be initializing that service. Going to call test bed and get rest API service. And after every test, we're going to be calling the http testing controller verifying method. The first test we're filling in will be the pagination of the tour packages list. So we will be using page index of two. And here's some test data that will be returned. And then we call the rest API service list tours method, with the page index and then subscribe to the result of that, and we expect the page to equal the test data. Since we are testing a rest API service, it will be using http client to actually make http requests. So we need to set up the request that we're expecting using the http testing controller. We expect one call to this particular API endpoint and we expect it to be…

Contents