From: Gustavo Martin Morcuende Date: Sun, 30 Aug 2015 19:18:11 +0000 (+0200) Subject: showcase: stubs X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=bdaf6ffdb11c586fe2839e0f364bfe84bb043414;p=JavaScriptForFun showcase: stubs --- diff --git a/angularjs/showcase/src/showcase/stubs/cars/cars.service.js b/angularjs/showcase/src/showcase/stubs/cars/cars.service.js new file mode 100644 index 0000000..a7b563b --- /dev/null +++ b/angularjs/showcase/src/showcase/stubs/cars/cars.service.js @@ -0,0 +1,27 @@ +(function () { + 'use strict'; + + angular + .module('app.stubs') + .factory('carsStub', carsStub); + + /* @ngInject */ + function carsStub($httpBackend, API) { + return { + register: register + }; + + function register() { + $httpBackend.whenGET(API.CARS).respond(getAll); + + function getAll() { + return [ + {id:1, content: 'Car: 1'}, + {id:2, content: 'Car: 2'}, + {id:3, content: 'Car: 3'} + ]; + } + } + } + +}()); diff --git a/angularjs/showcase/src/showcase/stubs/stubs.config.js b/angularjs/showcase/src/showcase/stubs/stubs.config.js new file mode 100644 index 0000000..5b31132 --- /dev/null +++ b/angularjs/showcase/src/showcase/stubs/stubs.config.js @@ -0,0 +1,14 @@ +(function () { + + 'use strict'; + + angular + .module('app.stubs') + .run('register', register); + + /* @ngInject */ + function register(carsStub) { + carsStub.register(); + } + +}()); diff --git a/angularjs/showcase/src/showcase/stubs/stubs.module.js b/angularjs/showcase/src/showcase/stubs/stubs.module.js new file mode 100644 index 0000000..e058d3e --- /dev/null +++ b/angularjs/showcase/src/showcase/stubs/stubs.module.js @@ -0,0 +1,23 @@ +(function () { + + 'use strict'; + + /** + * @ngdoc overview + * @name stubs + * + * @requires app + * @requires ngMockE2E + * + * @description + * # stubs + * + * ## Module stubs. + * Module in charge of creating stubs. + */ + angular.module('app.stubs', [ + 'app.core', + 'ngMockE2E' + ]); + +}());