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 component
From the course: Building Angular and Django Apps
Unit testing a component
- [Instructor] And now we're going to be unit testing an Angular component. We already have a test suite and two tests that we have to fill out. So, let's begin by setting up the test fixture, which is a component fixture with the tour package list component. And then, the component itself and because the component relies on a controller, we need to create a mock controller, and it's a jasmine spy object for the tour package controller. And now, before each test, we're going to be setting up the mock controller by creating a spy objects and we will be spying on two methods. Delete and list. The test bed is also being configured before every test. We will need to add a new provider which provides the tour package controller, I uses the value of the mock controller. After that, it's safe for us to create the fixture. And then, we get the reference to the fixture component instance that was created, that was…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.