AngularJS by Brad Green & Shyam Seshadri
Author:Brad Green & Shyam Seshadri
Language: eng
Format: epub
Tags: COMPUTERS / Internet / Application Development
ISBN: 9781449344849
Publisher: O’Reilly Media
Published: 2013-04-09T04:00:00+00:00
With that harness in place, let’s take a look at the unit tests for the List Controller:
describe('ListCtrl', function() { var mockBackend, recipe; // _$httpBackend_ is the same as $httpBackend. Only written this way to // differentiate between injected variables and local variables beforeEach(inject(function($rootScope, $controller, _$httpBackend_, Recipe) { recipe = Recipe; mockBackend = _$httpBackend_; $scope = $rootScope.$new(); ctrl = $controller('ListCtrl', { $scope: $scope, recipes: [1, 2, 3] }); })); it('should have list of recipes', function() { expect($scope.recipes).toEqual([1, 2, 3]); }); });
Remember that the List Controller is one of the simplest controllers we have. The constructor of the controller just takes in a list of recipes and saves it to the scope. You could write a test for it, but it seems kind of silly (we still did it, because tests are awesome!).
Instead, the more interesting aspect is the MultiRecipeLoader service. This is responsible for fetching the list of recipes from the server and passing it in as an argument (when hooked up correctly via the $route service):
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Hello! Python by Anthony Briggs(9915)
The Mikado Method by Ola Ellnestam Daniel Brolund(9778)
Dependency Injection in .NET by Mark Seemann(9339)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7778)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7557)
Svelte with Test-Driven Development by Daniel Irvine(7159)
Test-Driven Development with PHP 8 by Rainier Sarabia(6886)
Layered Design for Ruby on Rails Applications by Dementyev Vladimir;(6756)
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(6532)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6413)
Web Development with Django by Ben Shaw Saurabh Badhwar(6219)
React Application Architecture for Production by Alan Alickovic(5945)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(5806)
Kotlin in Action by Dmitry Jemerov(5063)
Audition by Ryu Murakami(4583)
Software Architecture for Web Developers by Mihaela Roxana Ghidersa(4452)
Hands-On Full-Stack Web Development with GraphQL and React by Sebastian Grebe(4317)
Accelerating Server-Side Development with Fastify by Manuel Spigolon Maksim Sinik & Matteo Collina(4298)
Functional Programming in JavaScript by Mantyla Dan(4038)
