showcase: stubs
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Sun, 30 Aug 2015 19:18:11 +0000 (21:18 +0200)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Sun, 30 Aug 2015 19:18:11 +0000 (21:18 +0200)
angularjs/showcase/src/showcase/stubs/cars/cars.service.js [new file with mode: 0644]
angularjs/showcase/src/showcase/stubs/stubs.config.js [new file with mode: 0644]
angularjs/showcase/src/showcase/stubs/stubs.module.js [new file with mode: 0644]

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 (file)
index 0000000..a7b563b
--- /dev/null
@@ -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 (file)
index 0000000..5b31132
--- /dev/null
@@ -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 (file)
index 0000000..e058d3e
--- /dev/null
@@ -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'
+  ]);
+
+}());