From bdaf6ffdb11c586fe2839e0f364bfe84bb043414 Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Sun, 30 Aug 2015 21:18:11 +0200 Subject: [PATCH] showcase: stubs --- .../src/showcase/stubs/cars/cars.service.js | 27 ++++++++++++++++++++++ .../showcase/src/showcase/stubs/stubs.config.js | 14 +++++++++++ .../showcase/src/showcase/stubs/stubs.module.js | 23 ++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 angularjs/showcase/src/showcase/stubs/cars/cars.service.js create mode 100644 angularjs/showcase/src/showcase/stubs/stubs.config.js create mode 100644 angularjs/showcase/src/showcase/stubs/stubs.module.js 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' + ]); + +}()); -- 2.1.4