We need a controller to communicate with the server. We will hook up a controller to the service.
- [Instructor] Welcome to the final video of the course,…Displaying Information with a Controller.…In the previous video, we created a directive…that uses the order service API to display the status…of a pizza order.…In this video, we will be updating our controller…to rely on the order service API.…We want to be able to create a controller…that relies on a service and be able to…rAPIdly develop unit tests…and end2end tests and update the fake API server.…In our pizza store web app,…we're going to display a coupon after the order…is delivered.…
We begin by defining the unit test for this…and the end2end test.…Let's open the unit test for the order service…and write the unit test for how we expect the coupon…display to work.…We set up the expectation…that there will be an http Get request made…through the http back end…which is used by the resource service.…When we make a request for a coupon,…we expect that the result will be some text…and a coupon code that the customer can print out…and use on their next order.…
AngularJS offers the perfect balance between layout and code, making the framework a favorite of developers around the world. But what you might not know is that Angular also provides an outstanding infrastructure for testing, for developing bug-free and easily maintainable applications. Learning AngularJS Testing helps you to understand the different aspects involved in testing Angular components, including controllers and directives, with the help of a practical pizza-ordering application.
Author Rudolf Olah starts by installing and initializing various helpful testing tools, such as Karma, Jasmine, and Grunt. Then he creates controllers for ordering the pizza and reviewing the order, and tests them with and without dependencies. Chapter 3 shows how to create accordion directives for the application, unit test them, and resolve the errors if these tests fail. Rudolf also goes through testing of the navigation between two controllers with the help of End2End testing. Finally, learn how to modify services to use the $resource module and interact with REST API web services, as well as unit test them with the help of mocks and spies. Rudolf also shows how to create and test directives and controllers that fetch information from the service and display it.
- Configuring Angular, Grunt, Karma, and Jasmine for testing
- Testing controllers
- Testing directives
- Inspecting the navigation between components with End2End testing
- Creating REST API services and unit testing them to make your app compelling and user friendly