Commit 024b96bb91bd12c1f9ef7420b60a95682fe6ad3b
Exists in
master
Merge branch 'master' into 'master'
Master(efernandez) See merge request !9
Showing
8 changed files
 
Show diff stats
gulpfile.js
| 1 | const templateCache = require('gulp-angular-templatecache'); | 1 | const templateCache = require('gulp-angular-templatecache'); | 
| 2 | const concat = require('gulp-concat'); | 2 | const concat = require('gulp-concat'); | 
| 3 | const clean = require('gulp-clean'); | 3 | const clean = require('gulp-clean'); | 
| 4 | const htmlmin = require('gulp-htmlmin'); | 4 | const htmlmin = require('gulp-htmlmin'); | 
| 5 | const rename = require('gulp-rename'); | 5 | const rename = require('gulp-rename'); | 
| 6 | const uglify = require('gulp-uglify-es').default; | 6 | const uglify = require('gulp-uglify-es').default; | 
| 7 | const gulp = require('gulp'); | 7 | const gulp = require('gulp'); | 
| 8 | const pump = require('pump'); | 8 | const pump = require('pump'); | 
| 9 | const jshint = require('gulp-jshint'); | 9 | const jshint = require('gulp-jshint'); | 
| 10 | const replace = require('gulp-replace'); | 10 | const replace = require('gulp-replace'); | 
| 11 | const connect = require('gulp-connect'); | 11 | const connect = require('gulp-connect'); | 
| 12 | const header = require('gulp-header'); | ||
| 13 | const footer = require('gulp-footer'); | ||
| 12 | 14 | ||
| 13 | var paths = { | 15 | var paths = { | 
| 14 | srcJS: 'src/js/*.js', | 16 | srcJS: 'src/js/*.js', | 
| 15 | srcViews: 'src/views/*.html', | 17 | srcViews: 'src/views/*.html', | 
| 18 | specs: 'spec/*.js', | ||
| 16 | tmp: 'tmp', | 19 | tmp: 'tmp', | 
| 17 | dist: 'dist/' | 20 | dist: 'dist/' | 
| 18 | }; | 21 | }; | 
| 19 | 22 | ||
| 20 | gulp.task('templates', function() { | 23 | gulp.task('templates', function() { | 
| 21 | return pump( | 24 | return pump( | 
| 22 | [ | 25 | [ | 
| 23 | gulp.src(paths.srcViews), | 26 | gulp.src(paths.srcViews), | 
| 24 | htmlmin(), | 27 | htmlmin(), | 
| 25 | templateCache('views.js', { | 28 | templateCache('views.js', { | 
| 26 | module: 'focaAbmPreciosCondiciones', | 29 | module: 'focaAbmPreciosCondiciones', | 
| 27 | root: '' | 30 | root: '' | 
| 28 | }), | 31 | }), | 
| 29 | gulp.dest(paths.tmp) | 32 | gulp.dest(paths.tmp) | 
| 30 | ] | 33 | ] | 
| 31 | ); | 34 | ); | 
| 32 | }); | 35 | }); | 
| 33 | 36 | ||
| 34 | gulp.task('uglify', ['templates'], function() { | 37 | gulp.task('uglify', ['templates', 'uglify-spec'], function() { | 
| 35 | return pump( | 38 | return pump( | 
| 36 | [ | 39 | [ | 
| 37 | gulp.src([ | 40 | gulp.src([ | 
| 38 | paths.srcJS, | 41 | paths.srcJS, | 
| 39 | 'tmp/views.js' | 42 | 'tmp/views.js' | 
| 40 | ]), | 43 | ]), | 
| 41 | concat('foca-abm-precios-condiciones.js'), | 44 | concat('foca-abm-precios-condiciones.js'), | 
| 42 | replace('src/views/', ''), | 45 | replace('src/views/', ''), | 
| 43 | replace("['ngRoute', 'ui.bootstrap', 'focaModal']", '[]'), | ||
| 44 | gulp.dest(paths.tmp), | 46 | gulp.dest(paths.tmp), | 
| 45 | rename('foca-abm-precios-condiciones.min.js'), | 47 | rename('foca-abm-precios-condiciones.min.js'), | 
| 46 | uglify(), | 48 | uglify(), | 
| 47 | gulp.dest(paths.dist) | 49 | gulp.dest(paths.dist) | 
| 48 | ] | 50 | ] | 
| 49 | ); | 51 | ); | 
| 50 | }); | 52 | }); | 
| 51 | 53 | ||
| 54 | gulp.task('uglify-spec', function() { | ||
| 55 | return pump([ | ||
| 56 | gulp.src(paths.specs), | ||
| 57 | concat('foca-abm-precios-condiciones.spec.js'), | ||
| 58 | replace("src/views/", ''), | ||
| 59 | header("describe('Módulo foca-abm-precios-condiciones', function() { \n"), | ||
| 60 | footer("});"), | ||
| 61 | gulp.dest(paths.dist) | ||
| 62 | ]); | ||
| 63 | }); | ||
| 64 | |||
| 52 | gulp.task('clean', function() { | 65 | gulp.task('clean', function() { | 
| 53 | return gulp.src(['tmp', 'dist'], {read: false}) | 66 | return gulp.src(['tmp', 'dist'], {read: false}) | 
| 54 | .pipe(clean()); | 67 | .pipe(clean()); | 
| 55 | }); | 68 | }); | 
| 56 | 69 | ||
| 57 | gulp.task('pre-commit', function() { | 70 | gulp.task('pre-commit', function() { | 
| 58 | pump( | 71 | return pump( | 
| 59 | [ | 72 | [ | 
| 60 | gulp.src(paths.srcJS), | 73 | gulp.src([paths.srcJS, paths.specs]), | 
| 61 | jshint('.jshintrc'), | 74 | jshint('.jshintrc'), | 
| 62 | jshint.reporter('default'), | 75 | jshint.reporter('default'), | 
| 63 | jshint.reporter('fail') | 76 | jshint.reporter('fail') | 
| 64 | ] | 77 | ] | 
| 65 | ); | 78 | ); | 
| 66 | }); | 79 | }); | 
| 67 | 80 | ||
| 68 | gulp.task('clean-post-install', function() { | 81 | gulp.task('clean-post-install', function() { | 
| 69 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | 82 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | 
| 70 | 'index.html'], {read: false}) | 83 | 'index.html', 'spec', 'test.html'], {read: false}) | 
| 71 | .pipe(clean()); | 84 | .pipe(clean()); | 
| 72 | }); | 85 | }); | 
| 73 | 86 | ||
| 74 | gulp.task('webserver', function() { | 87 | gulp.task('webserver', function() { | 
| 75 | pump [ | 88 | pump [ | 
| 76 | connect.server({port: 3000}) | 89 | connect.server({port: 3000}) | 
| 77 | ] | 90 | ] | 
| 78 | }); | 91 | }); | 
| 79 | 92 | ||
| 80 | gulp.task('default', ['webserver']); | 93 | gulp.task('default', ['webserver']); | 
index.html
| 1 | <html ng-app="focaAbmPreciosCondiciones"> | File was deleted | |
| 2 | |||
| 3 | <head> | ||
| 4 | <meta charset="UTF-8" /> | ||
| 5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
| 6 | |||
| 7 | <!--CSS--> | ||
| 8 | <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" /> | ||
| 9 | <link href="node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet" /> | ||
| 10 | |||
| 11 | <!--VENDOR JS--> | ||
| 12 | <script src="node_modules/jquery/dist/jquery.min.js"></script> | ||
| 13 | <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> | ||
| 14 | <script src="node_modules/angular/angular.min.js"></script> | ||
| 15 | <script src="node_modules/angular-route/angular-route.min.js"></script> | ||
| 16 | <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> | ||
| 17 | <script src="node_modules/foca-modal/dist/foca-modal.min.js"></script> | ||
| 18 | |||
| 19 | <!-- BUILD --> | ||
| 20 | <script src="src/js/app.js"></script> | ||
| 21 | <script src="src/js/route.js"></script> | ||
| 22 | <script src="src/js/controller.js"></script> | ||
| 23 | <script src="src/js/service.js"></script> | ||
| 24 | <script src="src/etc/develop.js"></script> | ||
| 25 | <!-- /BUILD --> | ||
| 26 | |||
| 27 | <body> | ||
| 28 | <div ng-view> | ||
| 29 | </div> | ||
| 30 | </body> | ||
| 31 | |||
| 32 | </html> | ||
| 33 | 1 | <html ng-app="focaAbmPreciosCondiciones"> | 
package.json
| 1 | { | 1 | { | 
| 2 | "name": "foca-abm-precios-condiciones", | 2 | "name": "foca-abm-precios-condiciones", | 
| 3 | "version": "1.0.0", | 3 | "version": "1.0.0", | 
| 4 | "description": "ABM de precios y condiciones", | 4 | "description": "ABM de precios y condiciones", | 
| 5 | "main": "dist/foca-abm-precios-condiciones.js", | 5 | "main": "dist/foca-abm-precios-condiciones.js", | 
| 6 | "scripts": { | 6 | "scripts": { | 
| 7 | "test": "echo \"Error: no test specified\" && exit 1", | 7 | "test": "test.html", | 
| 8 | "compile": "gulp uglify", | 8 | "compile": "gulp uglify", | 
| 9 | "gulp-pre-commit": "gulp pre-commit", | 9 | "gulp-pre-commit": "gulp pre-commit", | 
| 10 | "postinstall": "npm run compile && gulp clean-post-install", | 10 | "postinstall": "npm run compile && gulp clean-post-install", | 
| 11 | "install-dev": "npm install -D jasmine-core pre-commit angular angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify gulp-replace jquery jshint pump git+http://git.focasoftware.com/npm/foca-modal.git" | 11 | "install-dev": "npm install -D jasmine-core pre-commit angular angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify gulp-replace jquery jshint pump angular-mocks git+http://git.focasoftware.com/npm/foca-modal.git" | 
| 12 | }, | 12 | }, | 
| 13 | "pre-commit": [ | 13 | "pre-commit": [ | 
| 14 | "gulp-pre-commit" | 14 | "gulp-pre-commit" | 
| 15 | ], | 15 | ], | 
| 16 | "repository": { | 16 | "repository": { | 
| 17 | "type": "git", | 17 | "type": "git", | 
| 18 | "url": "https://192.168.0.11/modulos-npm/foca-abm-precios-condiciones.git" | 18 | "url": "https://192.168.0.11/modulos-npm/foca-abm-precios-condiciones.git" | 
| 19 | }, | 19 | }, | 
| 20 | "author": "Foca Software", | 20 | "author": "Foca Software", | 
| 21 | "license": "ISC", | 21 | "license": "ISC", | 
| 22 | "peerDependencies": { | 22 | "peerDependencies": { | 
| 23 | "angular": "^1.7.x", | 23 | "angular": "^1.7.x", | 
| 24 | "bootstrap": "^4.1.x", | 24 | "bootstrap": "^4.1.x", | 
| 25 | "jquery": "^3.3.x", | 25 | "jquery": "^3.3.x", | 
| 26 | "font-awesome": "^4.7.x", | 26 | "font-awesome": "^4.7.x", | 
| 27 | "gulp": "^3.9.x", | 27 | "gulp": "^3.9.x", | 
| 28 | "gulp-concat": "2.6.x", | 28 | "gulp-concat": "2.6.x", | 
| 29 | "gulp-jshint": "^2.1.x", | 29 | "gulp-jshint": "^2.1.x", | 
| 30 | "gulp-rename": "^1.4.x", | 30 | "gulp-rename": "^1.4.x", | 
| 31 | "gulp-replace": "^1.0.x", | 31 | "gulp-replace": "^1.0.x", | 
| 32 | "gulp-uglify-es": "^1.0.x", | 32 | "gulp-uglify-es": "^1.0.x", | 
| 33 | "jshint": "^2.9.x", | 33 | "jshint": "^2.9.x", | 
| 34 | "pump": "^3.0.x" | 34 | "pump": "^3.0.x" | 
| 35 | }, | 35 | }, | 
| 36 | "devDependencies": { | 36 | "devDependencies": { | 
| 37 | "angular": "^1.7.4", | 37 | "angular": "^1.7.7", | 
| 38 | "angular-route": "^1.7.5", | 38 | "angular-mocks": "^1.7.7", | 
| 39 | "bootstrap": "^4.1.3", | 39 | "angular-route": "^1.7.7", | 
| 40 | "bootstrap": "^4.2.1", | ||
| 40 | "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", | 41 | "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", | 
| 41 | "font-awesome": "^4.7.0", | 42 | "font-awesome": "^4.7.0", | 
| 42 | "gulp": "^3.9.1", | 43 | "gulp": "^3.9.1", | 
| 43 | "gulp-angular-templatecache": "^2.2.1", | 44 | "gulp-angular-templatecache": "^2.2.6", | 
| 44 | "gulp-clean": "^0.4.0", | 45 | "gulp-clean": "^0.4.0", | 
| 45 | "gulp-connect": "^5.6.1", | 46 | "gulp-connect": "^5.7.0", | 
| 46 | "gulp-htmlmin": "^5.0.1", | 47 | "gulp-htmlmin": "^5.0.1", | 
| 47 | "gulp-jshint": "^2.1.0", | 48 | "gulp-jshint": "^2.1.0", | 
| 48 | "gulp-rename": "^1.4.0", | 49 | "gulp-rename": "^1.4.0", | 
| 49 | "gulp-replace": "^1.0.0", | 50 | "gulp-replace": "^1.0.0", | 
| 50 | "gulp-sequence": "^1.0.0", | 51 | "gulp-sequence": "^1.0.0", | 
| 51 | "gulp-uglify": "^3.0.1", | 52 | "gulp-uglify": "^3.0.1", | 
| 52 | "gulp-uglify-es": "^1.0.4", | 53 | "gulp-uglify-es": "^1.0.4", | 
| 53 | "jasmine-core": "^3.2.1", | 54 | "jasmine-core": "^3.3.0", | 
| 54 | "jquery": "^3.3.1", | 55 | "jquery": "^3.3.1", | 
| 55 | "jshint": "^2.9.6", | 56 | "jshint": "^2.10.1", | 
| 56 | "pre-commit": "^1.2.2", | 57 | "pre-commit": "^1.2.2", | 
| 57 | "pump": "^3.0.0", | 58 | "pump": "^3.0.0", | 
| 58 | "ui-bootstrap4": "^3.0.5" | 59 | "ui-bootstrap4": "^3.0.6" | 
| 59 | } | 60 | } | 
| 60 | } | 61 | } | 
| 61 | 62 | 
spec/controllerSpec.js
| File was created | 1 | describe('Controladores abm precios condiciones', function() { | |
| 2 | |||
| 3 | var $controller; | ||
| 4 | var timeout; | ||
| 5 | |||
| 6 | beforeEach(function() { | ||
| 7 | module('focaAbmPreciosCondiciones'); | ||
| 8 | inject(function(_$controller_) { | ||
| 9 | $controller = _$controller_; | ||
| 10 | }); | ||
| 11 | }); | ||
| 12 | |||
| 13 | beforeEach(function() { | ||
| 14 | inject(function($timeout) { | ||
| 15 | timeout = $timeout; | ||
| 16 | }); | ||
| 17 | }); | ||
| 18 | |||
| 19 | describe('Controlador focaAbmPreciosCondiciones', function() { | ||
| 20 | |||
| 21 | it('Existe el controlador', function() { | ||
| 22 | //act | ||
| 23 | var controlador = $controller('focaAbmPreciosCondicionesController', { | ||
| 24 | $scope: {}, | ||
| 25 | focaAbmPreciosCondicionesService: {}, | ||
| 26 | $location: {}, | ||
| 27 | focaModalService: {}, | ||
| 28 | focaBotoneraLateralService: {}, | ||
| 29 | $timeout: timeout | ||
| 30 | }); | ||
| 31 | |||
| 32 | //assert | ||
| 33 | expect(typeof controlador).toEqual('object'); | ||
| 34 | }); | ||
| 35 | |||
| 36 | it('$scope.editar lleva a la ruta correcta', function() { | ||
| 37 | inject(function($location) { | ||
| 38 | //arrange | ||
| 39 | var scope = {}; | ||
| 40 | var paramFake = 1; | ||
| 41 | $controller('focaAbmPreciosCondicionesController', { | ||
| 42 | $scope: scope, | ||
| 43 | focaAbmPreciosCondicionesService: {}, | ||
| 44 | $location: $location, | ||
| 45 | focaModalService: {}, | ||
| 46 | focaBotoneraLateralService: {}, | ||
| 47 | $timeout: timeout | ||
| 48 | }); | ||
| 49 | |||
| 50 | |||
| 51 | //act | ||
| 52 | scope.editar(paramFake); | ||
| 53 | |||
| 54 | //assert | ||
| 55 | expect($location.url()).toEqual('/precio-condicion/' + paramFake); | ||
| 56 | }); | ||
| 57 | }); | ||
| 58 | |||
| 59 | it('$scope.solicitarConfirmacion levanta modal confirm', function() { | ||
| 60 | //arrange | ||
| 61 | var scope = {}; | ||
| 62 | var paramFake = 1; | ||
| 63 | var focaModalService = { | ||
| 64 | confirm: function() { } | ||
| 65 | }; | ||
| 66 | $controller('focaAbmPreciosCondicionesController', { | ||
| 67 | $scope: scope, | ||
| 68 | focaAbmPreciosCondicionesService: {}, | ||
| 69 | $location: {}, | ||
| 70 | focaModalService: focaModalService, | ||
| 71 | focaBotoneraLateralService: {}, | ||
| 72 | $timeout: timeout | ||
| 73 | }); | ||
| 74 | |||
| 75 | //act | ||
| 76 | spyOn(focaModalService, 'confirm').and.returnValue({ then: function() { }}); | ||
| 77 | scope.solicitarConfirmacion(paramFake); | ||
| 78 | |||
| 79 | //assert | ||
| 80 | expect(focaModalService.confirm).toHaveBeenCalled(); | ||
| 81 | }); | ||
| 82 | |||
| 83 | it('$scope.solicitarConfirmacion elimina al confirmar ok', function(done) { | ||
| 84 | //arrange | ||
| 85 | var scope = {}; | ||
| 86 | var paramFake = 1; | ||
| 87 | var focaModalService = { | ||
| 88 | confirm: function() { } | ||
| 89 | }; | ||
| 90 | var focaAbmPreciosCondicionesService = { | ||
| 91 | borrarPrecioCondicion: function() { } | ||
| 92 | }; | ||
| 93 | $controller('focaAbmPreciosCondicionesController', { | ||
| 94 | $scope: scope, | ||
| 95 | focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, | ||
| 96 | $location: {}, | ||
| 97 | focaModalService: focaModalService, | ||
| 98 | focaBotoneraLateralService: {}, | ||
| 99 | $timeout: timeout | ||
| 100 | }); | ||
| 101 | var promesaConfirm = Promise.resolve(true); | ||
| 102 | scope.preciosCondiciones = []; | ||
| 103 | |||
| 104 | //act | ||
| 105 | spyOn(focaModalService, 'confirm').and.returnValue(promesaConfirm); | ||
| 106 | spyOn(focaAbmPreciosCondicionesService, 'borrarPrecioCondicion'); | ||
| 107 | scope.solicitarConfirmacion(paramFake); | ||
| 108 | |||
| 109 | //assert | ||
| 110 | promesaConfirm.then(function() { | ||
| 111 | expect(focaAbmPreciosCondicionesService.borrarPrecioCondicion).toHaveBeenCalled(); | ||
| 112 | done(); | ||
| 113 | }); | ||
| 114 | }); | ||
| 115 | |||
| 116 | it('$scope.buscar llama a obtenerPreciosCondiciones', function() { | ||
| 117 | //arrange | ||
| 118 | var scope = {}; | ||
| 119 | var focaAbmPreciosCondicionesService = { | ||
| 120 | obtenerPreciosCondiciones: function() { } | ||
| 121 | }; | ||
| 122 | $controller('focaAbmPreciosCondicionesController', { | ||
| 123 | $scope: scope, | ||
| 124 | focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, | ||
| 125 | $location: {}, | ||
| 126 | focaModalService: {}, | ||
| 127 | focaBotoneraLateralService: {}, | ||
| 128 | $timeout: timeout | ||
| 129 | }); | ||
| 130 | |||
| 131 | //act | ||
| 132 | spyOn(focaAbmPreciosCondicionesService, 'obtenerPreciosCondiciones') | ||
| 133 | .and.returnValue({ then: function() { }}); | ||
| 134 | scope.buscar(13); | ||
| 135 | |||
| 136 | //assert | ||
| 137 | expect(focaAbmPreciosCondicionesService.obtenerPreciosCondiciones).toHaveBeenCalled(); | ||
| 138 | }); | ||
| 139 | }); | ||
| 140 | |||
| 141 | describe('Controlador focaAbmPrecioCondicionController', function() { | ||
| 142 | |||
| 143 | it('Existe el controlador focaAbmPrecioCondicionController', function() { | ||
| 144 | //act | ||
| 145 | var controlador = $controller('focaAbmPrecioCondicionController', { | ||
| 146 | $scope: {}, | ||
| 147 | focaAbmPreciosCondicionesService: { | ||
| 148 | obtenerPrecioCondicion: function() { | ||
| 149 | return { | ||
| 150 | then: function() { } | ||
| 151 | }; | ||
| 152 | } | ||
| 153 | }, | ||
| 154 | focaBotoneraLateralService: {}, | ||
| 155 | $routeParams: {}, | ||
| 156 | $location: {}, | ||
| 157 | focaModalService: {}, | ||
| 158 | $timeout: timeout, | ||
| 159 | $uibModal: {}, | ||
| 160 | $window: {} | ||
| 161 | }); | ||
| 162 | |||
| 163 | //assert | ||
| 164 | expect(typeof controlador).toEqual('object'); | ||
| 165 | }); | ||
| 166 | |||
| 167 | it('La funcion $scope.cancelar lleva a la ruta correcta', function() { | ||
| 168 | inject(function($location) { | ||
| 169 | //arrange | ||
| 170 | var scope = {}; | ||
| 171 | $controller('focaAbmPrecioCondicionController', { | ||
| 172 | $scope: scope, | ||
| 173 | focaAbmPreciosCondicionesService: { | ||
| 174 | obtenerPrecioCondicion: function() { | ||
| 175 | return { | ||
| 176 | then: function() { } | ||
| 177 | }; | ||
| 178 | } | ||
| 179 | }, | ||
| 180 | focaBotoneraLateralService: {}, | ||
| 181 | $routeParams: {}, | ||
| 182 | $location: $location, | ||
| 183 | focaModalService: {}, | ||
| 184 | $timeout: timeout, | ||
| 185 | $uibModal: {}, | ||
| 186 | $window: {} | ||
| 187 | }); | ||
| 188 | |||
| 189 | //act | ||
| 190 | scope.cancelar(); | ||
| 191 | |||
| 192 | //assert | ||
| 193 | expect($location.url()).toEqual('/precio-condicion'); | ||
| 194 | }); | ||
| 195 | }); | ||
| 196 | |||
| 197 | it('La funcion $scope.guardar llama a servicio.guardarPrecioCondicion', function() { | ||
| 198 | inject(function($location) { | ||
| 199 | //arrange | ||
| 200 | var scope = {}; | ||
| 201 | var focaAbmPreciosCondicionesService = { | ||
| 202 | obtenerPrecioCondicion: function() { | ||
| 203 | return { | ||
| 204 | then: function() { } | ||
| 205 | }; | ||
| 206 | }, | ||
| 207 | guardarPrecioCondicion: function() { } | ||
| 208 | }; | ||
| 209 | var window = { | ||
| 210 | location: { | ||
| 211 | assign: function() { } | ||
| 212 | } | ||
| 213 | }; | ||
| 214 | $controller('focaAbmPrecioCondicionController', { | ||
| 215 | $scope: scope, | ||
| 216 | focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, | ||
| 217 | focaBotoneraLateralService: {}, | ||
| 218 | $routeParams: {}, | ||
| 219 | $location: $location, | ||
| 220 | focaModalService: {}, | ||
| 221 | $timeout: timeout, | ||
| 222 | $uibModal: {}, | ||
| 223 | $window: window | ||
| 224 | }); | ||
| 225 | var promesaGuardarPrecioCondicion = Promise.resolve(true); | ||
| 226 | scope.precioCondicion = { listaPrecio: {} }; | ||
| 227 | |||
| 228 | //act | ||
| 229 | //spyOn(window, 'location').and.returnValue({ assign: function() {} }); | ||
| 230 | spyOn(focaAbmPreciosCondicionesService, 'guardarPrecioCondicion') | ||
| 231 | .and.returnValue(promesaGuardarPrecioCondicion); | ||
| 232 | scope.guardar(); | ||
| 233 | |||
| 234 | //assert | ||
| 235 | expect(focaAbmPreciosCondicionesService.guardarPrecioCondicion).toHaveBeenCalled(); | ||
| 236 | }); | ||
| 237 | }); | ||
| 238 | |||
| 239 | it('La funcion $scope.solicitarConfirmacionPlazoPago levanta modal confirm', function() { | ||
| 240 | //act | ||
| 241 | var scope = {}; | ||
| 242 | var focaModalService = { | ||
| 243 | confirm: function() { } | ||
| 244 | }; | ||
| 245 | $controller('focaAbmPrecioCondicionController', { | ||
| 246 | $scope: scope, | ||
| 247 | focaAbmPreciosCondicionesService: { | ||
| 248 | obtenerPrecioCondicion: function() { | ||
| 249 | return { | ||
| 250 | then:function() { } | ||
| 251 | }; | ||
| 252 | } | ||
| 253 | }, | ||
| 254 | focaBotoneraLateralService: {}, | ||
| 255 | $routeParams: {}, | ||
| 256 | $location: {}, | ||
| 257 | focaModalService: focaModalService, | ||
| 258 | $timeout: timeout, | ||
| 259 | $uibModal: {}, | ||
| 260 | $window: {} | ||
| 261 | }); | ||
| 262 | |||
| 263 | //act | ||
| 264 | spyOn(focaModalService, 'confirm') | ||
| 265 | .and.returnValue({ then: function() {} }); | ||
| 266 | scope.solicitarConfirmacionPlazoPago({ data: 'test' }); | ||
| 267 | |||
| 268 | //assert | ||
| 269 | expect(focaModalService.confirm).toHaveBeenCalled(); | ||
| 270 | }); | ||
| 271 | |||
| 272 | it('La funcion $scope.solicitarConfirmacionPlazoPago borra al dar ok', function(done) { | ||
| 273 | //act | ||
| 274 | var scope = {}; | ||
| 275 | var focaModalService = { | ||
| 276 | confirm: function() { } | ||
| 277 | }; | ||
| 278 | var focaAbmPreciosCondicionesService = { | ||
| 279 | obtenerPrecioCondicion: function() { | ||
| 280 | return { | ||
| 281 | then:function() { } | ||
| 282 | }; | ||
| 283 | }, | ||
| 284 | borrarPlazoPago: function() { } | ||
| 285 | }; | ||
| 286 | $controller('focaAbmPrecioCondicionController', { | ||
| 287 | $scope: scope, | ||
| 288 | focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, | ||
| 289 | focaBotoneraLateralService: {}, | ||
| 290 | $routeParams: {}, | ||
| 291 | $location: {}, | ||
| 292 | focaModalService: focaModalService, | ||
| 293 | $timeout: timeout, | ||
| 294 | $uibModal: {}, | ||
| 295 | $window: {} | ||
| 296 | }); | ||
| 297 | var promesaConfirm = Promise.resolve(true); | ||
| 298 | scope.precioCondicion = { | ||
| 299 | plazos: [] | ||
| 300 | }; | ||
| 301 | |||
| 302 | //act | ||
| 303 | spyOn(focaModalService, 'confirm').and.returnValue(promesaConfirm); | ||
| 304 | spyOn(focaAbmPreciosCondicionesService, 'borrarPlazoPago'); | ||
| 305 | scope.solicitarConfirmacionPlazoPago({ data: 'test' }); | ||
| 306 | |||
| 307 | //assert | ||
| 308 | promesaConfirm.then(function() { | ||
| 309 | expect(focaAbmPreciosCondicionesService.borrarPlazoPago).toHaveBeenCalled(); | ||
| 310 | done(); | ||
| 311 | }); | ||
| 312 | }); | ||
| 313 | |||
| 314 | it('La funcion $scope.seleccionarListaPrecio levanta modal', function() { | ||
| 315 | //arrange | ||
| 316 | var scope = {}; | ||
| 317 | var uibModal = { | ||
| 318 | open: function() { } | ||
| 319 | }; | ||
| 320 | var focaAbmPreciosCondicionesService = { | ||
| 321 | obtenerPrecioCondicion: function() { | ||
| 322 | return { | ||
| 323 | then:function() { } | ||
| 324 | }; | ||
| 325 | } | ||
| 326 | }; | ||
| 327 | $controller('focaAbmPrecioCondicionController', { | ||
| 328 | $scope: scope, | ||
| 329 | focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, | ||
| 330 | focaBotoneraLateralService: {}, | ||
| 331 | $routeParams: {}, | ||
| 332 | $location: {}, | ||
| 333 | focaModalService: {}, | ||
| 334 | $timeout: timeout, | ||
| 335 | $uibModal: uibModal, | ||
| 336 | $window: {} | ||
| 337 | }); | ||
| 338 | |||
| 339 | //act | ||
| 340 | spyOn(uibModal, 'open').and.returnValue({ result: { then: function() { } } }); | ||
| 341 | scope.seleccionarListaPrecio(13); | ||
| 342 | |||
| 343 | //assert | ||
| 344 | expect(uibModal.open).toHaveBeenCalled(); | ||
| 345 | }); | ||
| 346 | |||
| 347 | it('La funcion $scope.verProductosListaPrecio levanta modal', function() { | ||
| 348 | //arrange | ||
| 349 | var scope = {}; | ||
| 350 | var uibModal = { | ||
| 351 | open: function() { } | ||
| 352 | }; | ||
| 353 | var focaAbmPreciosCondicionesService = { | ||
| 354 | obtenerPrecioCondicion: function() { | ||
| 355 | return { | ||
| 356 | then:function() { } | ||
| 357 | }; | ||
| 358 | } | ||
| 359 | }; | ||
| 360 | $controller('focaAbmPrecioCondicionController', { | ||
| 361 | $scope: scope, | ||
| 362 | focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, | ||
| 363 | focaBotoneraLateralService: {}, | ||
| 364 | $routeParams: {}, | ||
| 365 | $location: {}, | ||
| 366 | focaModalService: {}, | ||
| 367 | $timeout: timeout, | ||
| 368 | $uibModal: uibModal, | ||
| 369 | $window: {} | ||
| 370 | }); | ||
| 371 | scope.precioCondicion = { | ||
| 372 | listaPrecio: {} | ||
| 373 | }; | ||
| 374 | //act | ||
| 375 | spyOn(uibModal, 'open'); | ||
| 376 | scope.verProductosListaPrecio(); | ||
| 377 | |||
| 378 | //assert | ||
| 379 | expect(uibModal.open).toHaveBeenCalled(); | ||
| 380 | }); | ||
| 381 | |||
| 382 | it('la función next suma uno a $scope.focused', function() { | ||
| 383 | //arrange | ||
| 384 | var scope = {}; | ||
| 385 | var focaAbmPreciosCondicionesService = { | ||
| 386 | obtenerPrecioCondicion: function() { | ||
| 387 | return { | ||
| 388 | then:function() { } | ||
| 389 | }; | ||
| 390 | } | ||
| 391 | }; | ||
| 392 | $controller('focaAbmPrecioCondicionController', { | ||
| 393 | $scope: scope, | ||
| 394 | focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, | ||
| 395 | focaBotoneraLateralService: {}, | ||
| 396 | $routeParams: {}, | ||
| 397 | $location: {}, | ||
| 398 | focaModalService: {}, | ||
| 399 | $timeout: timeout, | ||
| 400 | $uibModal: {}, | ||
| 401 | $window: {} | ||
| 402 | }); | ||
| 403 | |||
| 404 | //act | ||
| 405 | var esperado = scope.focused + 1; | ||
| 406 | scope.next(13); | ||
| 407 | |||
| 408 | //assert | ||
| 409 | expect(scope.focused).toEqual(esperado); | ||
| 410 | }); | ||
| 411 | }); | ||
| 412 | }); | ||
| 413 | 
spec/routeSpec.js
| File was created | 1 | describe('Rutas de abm precios condiciones', function() { | |
| 2 | |||
| 3 | var route; | ||
| 4 | |||
| 5 | beforeEach(function() { | ||
| 6 | module('focaAbmPreciosCondiciones'); | ||
| 7 | inject(function($route) { | ||
| 8 | route = $route; | ||
| 9 | }); | ||
| 10 | }); | ||
| 11 | |||
| 12 | it('Ruta /precio-condicion dirije correctamente', function() { | ||
| 13 | //assert | ||
| 14 | expect(route.routes['/precio-condicion'].controller) | ||
| 15 | .toBe('focaAbmPreciosCondicionesController'); | ||
| 16 | expect(route.routes['/precio-condicion'].templateUrl) | ||
| 17 | .toBe('src/views/foca-abm-precios-condiciones-listado.html'); | ||
| 18 | }); | ||
| 19 | |||
| 20 | it('Ruta /precio-condicion/:id dirije correctamente', function() { | ||
| 21 | //assert | ||
| 22 | expect(route.routes['/precio-condicion/:id'].controller) | ||
| 23 | .toBe('focaAbmPrecioCondicionController'); | ||
| 24 | expect(route.routes['/precio-condicion/:id'].templateUrl) | ||
| 25 | .toBe('src/views/foca-abm-precios-condiciones-item.html'); | ||
| 26 | }); | ||
| 27 | }); | ||
| 28 | 
spec/serviceSpec.js
| File was created | 1 | describe('Servicios abm precios condiciones', function() { | |
| 2 | |||
| 3 | var httpBackend; | ||
| 4 | |||
| 5 | beforeEach(function() { | ||
| 6 | module('focaAbmPreciosCondiciones'); | ||
| 7 | |||
| 8 | inject(module(function($provide) { | ||
| 9 | $provide.value('API_ENDPOINT', { | ||
| 10 | URL: 'localhost' | ||
| 11 | }); | ||
| 12 | })); | ||
| 13 | }); | ||
| 14 | |||
| 15 | describe('servicio focaAbmPreciosCondicionesService', function() { | ||
| 16 | |||
| 17 | var servicio; | ||
| 18 | |||
| 19 | beforeEach(function() { | ||
| 20 | inject(function(focaAbmPreciosCondicionesService, $httpBackend) { | ||
| 21 | servicio = focaAbmPreciosCondicionesService; | ||
| 22 | httpBackend = $httpBackend; | ||
| 23 | }); | ||
| 24 | }); | ||
| 25 | |||
| 26 | it('existe el servicio focaAbmPreciosCondicionesService', function() { | ||
| 27 | //assert | ||
| 28 | expect(typeof servicio).toEqual('object'); | ||
| 29 | }); | ||
| 30 | |||
| 31 | it('la función obtenerPreciosCondiciones llama ruta correcta', function() { | ||
| 32 | //arrange | ||
| 33 | var responseFake = { data: 'test'}; | ||
| 34 | var result; | ||
| 35 | var bodyFake = 1; | ||
| 36 | httpBackend.expectPOST('localhost/precios-condiciones', { nombre: bodyFake }) | ||
| 37 | .respond(responseFake); | ||
| 38 | |||
| 39 | //act | ||
| 40 | servicio.obtenerPreciosCondiciones(bodyFake).then(function(data) { | ||
| 41 | result = data.data; | ||
| 42 | }); | ||
| 43 | httpBackend.flush(); | ||
| 44 | |||
| 45 | //assert | ||
| 46 | expect(result).toEqual(responseFake); | ||
| 47 | }); | ||
| 48 | |||
| 49 | it('la función obtenerPrecioCondicion llama ruta correcta', function() { | ||
| 50 | //arrange | ||
| 51 | var responseFake = { data: 'test'}; | ||
| 52 | var result; | ||
| 53 | var paramFake = 1; | ||
| 54 | httpBackend.expectGET('localhost/precio-condicion/' + paramFake) | ||
| 55 | .respond(responseFake); | ||
| 56 | |||
| 57 | //act | ||
| 58 | servicio.obtenerPrecioCondicion(paramFake).then(function(data) { | ||
| 59 | result = data.data; | ||
| 60 | }); | ||
| 61 | httpBackend.flush(); | ||
| 62 | |||
| 63 | //assert | ||
| 64 | expect(result).toEqual(responseFake); | ||
| 65 | }); | ||
| 66 | |||
| 67 | it('la función guardarPrecioCondicion llama ruta correcta', function() { | ||
| 68 | //arrange | ||
| 69 | var responseFake = { data: 'test'}; | ||
| 70 | var result; | ||
| 71 | var bodyFake = 1; | ||
| 72 | httpBackend.expectPOST('localhost/precio-condicion', { precioCondicion: bodyFake }) | ||
| 73 | .respond(responseFake); | ||
| 74 | |||
| 75 | //act | ||
| 76 | servicio.guardarPrecioCondicion(bodyFake).then(function(data) { | ||
| 77 | result = data.data; | ||
| 78 | }); | ||
| 79 | httpBackend.flush(); | ||
| 80 | |||
| 81 | //assert | ||
| 82 | expect(result).toEqual(responseFake); | ||
| 83 | }); | ||
| 84 | |||
| 85 | it('la función borrarPrecioCondicion llama ruta correcta', function() { | ||
| 86 | //arrange | ||
| 87 | var responseFake = { data: 'test'}; | ||
| 88 | var result; | ||
| 89 | var paramFake = 1; | ||
| 90 | httpBackend.expectDELETE('localhost/precio-condicion/' + paramFake) | ||
| 91 | .respond(responseFake); | ||
| 92 | |||
| 93 | //act | ||
| 94 | servicio.borrarPrecioCondicion(paramFake).then(function(data) { | ||
| 95 | result = data.data; | ||
| 96 | }); | ||
| 97 | httpBackend.flush(); | ||
| 98 | |||
| 99 | //assert | ||
| 100 | expect(result).toEqual(responseFake); | ||
| 101 | }); | ||
| 102 | |||
| 103 | it('la función obtenerPlazoPago llama ruta correcta', function() { | ||
| 104 | //arrange | ||
| 105 | var responseFake = { data: 'test'}; | ||
| 106 | var result; | ||
| 107 | var paramFake = 1; | ||
| 108 | httpBackend.expectGET('localhost/plazo-pago/precio-condicion/' + paramFake) | ||
| 109 | .respond(responseFake); | ||
| 110 | |||
| 111 | //act | ||
| 112 | servicio.obtenerPlazoPago(paramFake).then(function(data) { | ||
| 113 | result = data.data; | ||
| 114 | }); | ||
| 115 | httpBackend.flush(); | ||
| 116 | |||
| 117 | //assert | ||
| 118 | expect(result).toEqual(responseFake); | ||
| 119 | }); | ||
| 120 | |||
| 121 | it('la función borrarPlazoPago llama ruta correcta', function() { | ||
| 122 | //arrange | ||
| 123 | var responseFake = { data: 'test'}; | ||
| 124 | var result; | ||
| 125 | var paramFake = 1; | ||
| 126 | httpBackend.expectDELETE('localhost/plazo-pago/' + paramFake) | ||
| 127 | .respond(responseFake); | ||
| 128 | |||
| 129 | //act | ||
| 130 | servicio.borrarPlazoPago(paramFake).then(function(data) { | ||
| 131 | result = data.data; | ||
| 132 | }); | ||
| 133 | httpBackend.flush(); | ||
| 134 | |||
| 135 | //assert | ||
| 136 | expect(result).toEqual(responseFake); | ||
| 137 | }); | ||
| 138 | |||
| 139 | it('la función guardarPlazosPago llama ruta correcta', function() { | ||
| 140 | //arrange | ||
| 141 | var responseFake = { data: 'test'}; | ||
| 142 | var result; | ||
| 143 | var bodyFake = 1; | ||
| 144 | httpBackend.expectPOST('localhost/plazos-pago', { plazosPago: bodyFake}) | ||
| 145 | .respond(responseFake); | ||
| 146 | |||
| 147 | //act | ||
| 148 | servicio.guardarPlazosPago(bodyFake).then(function(data) { | ||
| 149 | result = data.data; | ||
| 150 | }); | ||
| 151 | httpBackend.flush(); | ||
| 152 | |||
| 153 | //assert | ||
| 154 | expect(result).toEqual(responseFake); | ||
| 155 | }); | ||
| 156 | }); | ||
| 157 | }); | ||
| 158 | 
src/js/app.js
| 1 | angular.module('focaAbmPreciosCondiciones', [ | 1 | angular.module('focaAbmPreciosCondiciones', ['ngRoute']); | 
| 2 | 'ngRoute', | ||
| 3 | 'ui.bootstrap', | ||
| 4 | 'focaModal', | ||
| 5 | 'focaBotoneraLateral' | ||
| 6 | ]); | ||
| 7 | 2 | 
test.html
| File was created | 1 | <html> | |
| 2 | <head> | ||
| 3 | <link rel="stylesheet" type="text/css" href="node_modules/jasmine-core/lib/jasmine-core/jasmine.css"> | ||
| 4 | <meta charset="UTF-8" /> | ||
| 5 | </head> | ||
| 6 | <body> | ||
| 7 | <script type="text/javascript" src="node_modules/jasmine-core/lib/jasmine-core/jasmine.js"></script> | ||
| 8 | <script type="text/javascript" src="node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js"></script> | ||
| 9 | <script type="text/javascript" src="node_modules/jasmine-core/lib/jasmine-core/boot.js"></script> | ||
| 10 | <script type="text/javascript" src="node_modules/angular/angular.min.js"></script> | ||
| 11 | <script type="text/javascript" src="node_modules/angular-route/angular-route.min.js"></script> | ||
| 12 | <script type="text/javascript" src="node_modules/angular-mocks/angular-mocks.js"></script> | ||
| 13 | <script type="text/javascript" src="src/js/app.js"></script> | ||
| 14 | <script type="text/javascript" src="src/js/controller.js"></script> | ||
| 15 | <script type="text/javascript" src="src/js/service.js"></script> | ||
| 16 | <script type="text/javascript" src="src/js/route.js"></script> | ||
| 17 | <script type="text/javascript" src="spec/controllerSpec.js"></script> | ||
| 18 | <script type="text/javascript" src="spec/serviceSpec.js"></script> | ||
| 19 | <script type="text/javascript" src="spec/routeSpec.js"></script> | ||
| 20 | </body> | ||
| 21 | </html> | ||
| 22 |