From the course: Building Angular and Django Apps

Unlock the full course today

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

Unit testing a controller

Unit testing a controller

From the course: Building Angular and Django Apps

Start my 1-month free trial

Unit testing a controller

- Now we're going to be testing the TourPackageController. The controller sits between between our components and the RestApiService. When we unit test it, we are testing that it's using the RestApiService correctly. So we have the... mockService and the controller. We're going to configure the mockService with a jasmine spy object. And we're mocking out the createTour... updateTour... listTours... and a few other methods here. Then we go down to the providers, configuration of the test bed, and then we add... the RestApiService as something we will be mocking out. And we also add the TourPackageController itself because... before every test we'll also be injecting the TourPackageController. And storing that after it's been initialized. Now the first unit test we're filling in around line 34 we'll call the "tour package getTour method" from the RestApiService. So we're going to have the controller, we're…

Contents