Commit 71d49b911642941668dfb6d1cc463a8b10412e1d
Exists in
master
Merge remote-tracking branch 'upstream/develop'
Showing
7 changed files
Show diff stats
package.json
| ... | ... | @@ -4,7 +4,7 @@ |
| 4 | 4 | "description": "Listado y ABM nota de remitos", |
| 5 | 5 | "main": "index.js", |
| 6 | 6 | "scripts": { |
| 7 | - "test": "echo \"Error: no test specified\" && exit 1", | |
| 7 | + "test": "test.html", | |
| 8 | 8 | "compile": "gulp uglify", |
| 9 | 9 | "gulp-pre-commit": "gulp pre-commit", |
| 10 | 10 | "postinstall": "npm run compile && gulp clean-post-install", |
| ... | ... | @@ -31,6 +31,7 @@ |
| 31 | 31 | "angular": "^1.7.5", |
| 32 | 32 | "angular-cookies": "^1.7.5", |
| 33 | 33 | "angular-ladda": "^0.4.3", |
| 34 | + "angular-mocks": "^1.7.7", | |
| 34 | 35 | "angular-route": "^1.7.5", |
| 35 | 36 | "bootstrap": "^4.1.3", |
| 36 | 37 | "foca-botonera-facturador": "git+http://git.focasoftware.com/npm/foca-botonera-facturador.git", |
| ... | ... | @@ -42,10 +43,7 @@ |
| 42 | 43 | "foca-modal-cotizacion": "git+http://git.focasoftware.com/npm/foca-modal-cotizacion.git", |
| 43 | 44 | "foca-modal-domicilio": "git+http://git.focasoftware.com/npm/foca-modal-domicilio.git", |
| 44 | 45 | "foca-modal-flete": "git+http://git.focasoftware.com/npm/foca-modal-flete.git", |
| 45 | - "foca-modal-moneda": "git+http://git.focasoftware.com/npm/foca-modal-moneda.git", | |
| 46 | 46 | "foca-modal-precio-condiciones": "git+http://git.focasoftware.com/npm/foca-modal-precio-condiciones.git", |
| 47 | - "foca-modal-proveedor": "git+http://git.focasoftware.com/npm/foca-modal-proveedor.git", | |
| 48 | - "foca-modal-vendedores": "git+http://git.focasoftware.com/npm/foca-modal-vendedores.git", | |
| 49 | 47 | "foca-seguimiento": "git+http://git.focasoftware.com/npm/foca-seguimiento.git", |
| 50 | 48 | "font-awesome": "^4.7.0", |
| 51 | 49 | "gulp": "^3.9.1", |
spec/controllerSpec.js
spec/routeSpec.js
| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | +describe('Rutas de módulo crear remito', function() { | |
| 2 | + | |
| 3 | + var route; | |
| 4 | + | |
| 5 | + beforeEach(function() { | |
| 6 | + | |
| 7 | + module('focaCrearRemito'); | |
| 8 | + inject(function($route) { | |
| 9 | + route = $route; | |
| 10 | + }); | |
| 11 | + }); | |
| 12 | + | |
| 13 | + it('la ruta /venta-remito/crear lleva a la ruta correcta', function() { | |
| 14 | + | |
| 15 | + //assert | |
| 16 | + expect(route.routes['/venta-remito/crear'].controller) | |
| 17 | + .toEqual('remitoController'); | |
| 18 | + expect(route.routes['/venta-remito/crear'].templateUrl) | |
| 19 | + .toEqual('src/views/remito.html'); | |
| 20 | + }); | |
| 21 | +}); |
spec/serviceSpec.js
| ... | ... | @@ -0,0 +1,393 @@ |
| 1 | +describe('Servicios modulo crear remito', function() { | |
| 2 | + | |
| 3 | + beforeEach(function(){ | |
| 4 | + module('focaCrearRemito'); | |
| 5 | + inject(module(function($provide) { | |
| 6 | + $provide.value('API_ENDPOINT', { | |
| 7 | + URL: 'localhost' | |
| 8 | + }); | |
| 9 | + })); | |
| 10 | + }); | |
| 11 | + | |
| 12 | + describe('servicio crearRemitoService', function() { | |
| 13 | + | |
| 14 | + var servicio, httpBackend; | |
| 15 | + | |
| 16 | + beforeEach(function() { | |
| 17 | + inject(function($httpBackend, _crearRemitoService_) { | |
| 18 | + servicio = _crearRemitoService_; | |
| 19 | + httpBackend = $httpBackend; | |
| 20 | + }); | |
| 21 | + }) | |
| 22 | + | |
| 23 | + it('existe el servicio crearRemitoService', function() { | |
| 24 | + | |
| 25 | + //assert | |
| 26 | + expect(typeof servicio).toEqual('object'); | |
| 27 | + }); | |
| 28 | + | |
| 29 | + it('función crearRemito llama a ruta correcta', function() { | |
| 30 | + | |
| 31 | + //arrange | |
| 32 | + var result; | |
| 33 | + var fakeParam = 1; | |
| 34 | + var respond = 'test'; | |
| 35 | + httpBackend.expectPOST('localhost/remito', fakeParam).respond(respond); | |
| 36 | + | |
| 37 | + //act | |
| 38 | + servicio.crearRemito(fakeParam).then(function(res) { | |
| 39 | + result = res.data; | |
| 40 | + }); | |
| 41 | + httpBackend.flush(); | |
| 42 | + | |
| 43 | + //assert | |
| 44 | + expect(result).toEqual(respond); | |
| 45 | + }); | |
| 46 | + | |
| 47 | + it('función getRemitoById llama a ruta correcta', function() { | |
| 48 | + | |
| 49 | + //arrange | |
| 50 | + var result; | |
| 51 | + var fakeParam = 1; | |
| 52 | + var respond = 'test'; | |
| 53 | + httpBackend.expectGET('localhost/remito/obtener/' + fakeParam).respond(respond); | |
| 54 | + | |
| 55 | + //act | |
| 56 | + servicio.getRemitoById(fakeParam).then(function(res) { | |
| 57 | + result = res.data; | |
| 58 | + }); | |
| 59 | + httpBackend.flush(); | |
| 60 | + | |
| 61 | + //assert | |
| 62 | + expect(result).toEqual(respond); | |
| 63 | + }); | |
| 64 | + | |
| 65 | + it('función obtenerRemito llama a ruta correcta', function() { | |
| 66 | + | |
| 67 | + //arrange | |
| 68 | + var result; | |
| 69 | + var fakeParam = 1; | |
| 70 | + var respond = 'test'; | |
| 71 | + httpBackend.expectGET('localhost/nota-pedido').respond(respond); | |
| 72 | + | |
| 73 | + //act | |
| 74 | + servicio.obtenerRemito(fakeParam).then(function(res) { | |
| 75 | + result = res.data; | |
| 76 | + }); | |
| 77 | + httpBackend.flush(); | |
| 78 | + | |
| 79 | + //assert | |
| 80 | + expect(result).toEqual(respond); | |
| 81 | + }); | |
| 82 | + | |
| 83 | + it('función setRemito setea correctamente', function() { | |
| 84 | + | |
| 85 | + //arrange | |
| 86 | + var result; | |
| 87 | + var fakeParam = 1; | |
| 88 | + | |
| 89 | + //act | |
| 90 | + servicio.setRemito(fakeParam); | |
| 91 | + | |
| 92 | + //assert | |
| 93 | + expect(servicio.remito).toEqual(fakeParam); | |
| 94 | + }); | |
| 95 | + | |
| 96 | + it('función clearRemito setea correctamente', function() { | |
| 97 | + | |
| 98 | + //act | |
| 99 | + servicio.clearRemito(); | |
| 100 | + | |
| 101 | + //assert | |
| 102 | + expect(servicio.remito).toEqual(undefined); | |
| 103 | + }); | |
| 104 | + | |
| 105 | + it('función getRemito trae correctamente', function() { | |
| 106 | + | |
| 107 | + //arrange | |
| 108 | + var fakeParam = 1; | |
| 109 | + | |
| 110 | + //act | |
| 111 | + servicio.remito = fakeParam; | |
| 112 | + var result = servicio.getRemito(); | |
| 113 | + | |
| 114 | + //assert | |
| 115 | + expect(result).toEqual(fakeParam); | |
| 116 | + }); | |
| 117 | + | |
| 118 | + it('función getArticulosByIdRemito llama a ruta correcta', function() { | |
| 119 | + | |
| 120 | + //arrange | |
| 121 | + var result; | |
| 122 | + var fakeParam = 1; | |
| 123 | + var respond = 'test'; | |
| 124 | + httpBackend.expectGET('localhost/articulos/nota-pedido/' + fakeParam).respond(respond); | |
| 125 | + | |
| 126 | + //act | |
| 127 | + servicio.getArticulosByIdRemito(fakeParam).then(function(res) { | |
| 128 | + result = res.data; | |
| 129 | + }); | |
| 130 | + httpBackend.flush(); | |
| 131 | + | |
| 132 | + //assert | |
| 133 | + expect(result).toEqual(respond); | |
| 134 | + }); | |
| 135 | + | |
| 136 | + it('función crearArticulosParaRemito llama a ruta correcta', function() { | |
| 137 | + | |
| 138 | + //arrange | |
| 139 | + var result; | |
| 140 | + var fakeParam = 1; | |
| 141 | + var respond = 'test'; | |
| 142 | + httpBackend.expectPOST('localhost/articulos/remito', {articuloRemito: fakeParam}) | |
| 143 | + .respond(respond); | |
| 144 | + | |
| 145 | + //act | |
| 146 | + servicio.crearArticulosParaRemito(fakeParam).then(function(res) { | |
| 147 | + result = res.data; | |
| 148 | + }); | |
| 149 | + httpBackend.flush(); | |
| 150 | + | |
| 151 | + //assert | |
| 152 | + expect(result).toEqual(respond); | |
| 153 | + }); | |
| 154 | + | |
| 155 | + it('función getDomiciliosByIdRemito llama a ruta correcta', function() { | |
| 156 | + | |
| 157 | + //arrange | |
| 158 | + var result; | |
| 159 | + var fakeParam = 1; | |
| 160 | + var respond = 'test'; | |
| 161 | + httpBackend.expectGET('localhost/nota-pedido/' + fakeParam + '/domicilios') | |
| 162 | + .respond(respond); | |
| 163 | + | |
| 164 | + //act | |
| 165 | + servicio.getDomiciliosByIdRemito(fakeParam).then(function(res) { | |
| 166 | + result = res.data; | |
| 167 | + }); | |
| 168 | + httpBackend.flush(); | |
| 169 | + | |
| 170 | + //assert | |
| 171 | + expect(result).toEqual(respond); | |
| 172 | + }); | |
| 173 | + | |
| 174 | + it('función getDomiciliosByIdCliente llama a ruta correcta', function() { | |
| 175 | + | |
| 176 | + //arrange | |
| 177 | + var result; | |
| 178 | + var fakeParam = 1; | |
| 179 | + var respond = 'test'; | |
| 180 | + httpBackend.expectGET('localhost/domicilio/tipo/2/cliente/' + fakeParam) | |
| 181 | + .respond(respond); | |
| 182 | + | |
| 183 | + //act | |
| 184 | + servicio.getDomiciliosByIdCliente(fakeParam).then(function(res) { | |
| 185 | + result = res.data; | |
| 186 | + }); | |
| 187 | + httpBackend.flush(); | |
| 188 | + | |
| 189 | + //assert | |
| 190 | + expect(result).toEqual(respond); | |
| 191 | + }); | |
| 192 | + | |
| 193 | + it('función getPrecioCondicion llama a ruta correcta', function() { | |
| 194 | + | |
| 195 | + //arrange | |
| 196 | + var result; | |
| 197 | + var respond = 'test'; | |
| 198 | + httpBackend.expectGET('localhost/precio-condicion').respond(respond); | |
| 199 | + | |
| 200 | + //act | |
| 201 | + servicio.getPrecioCondicion().then(function(res) { | |
| 202 | + result = res.data; | |
| 203 | + }); | |
| 204 | + httpBackend.flush(); | |
| 205 | + | |
| 206 | + //assert | |
| 207 | + expect(result).toEqual(respond); | |
| 208 | + }); | |
| 209 | + | |
| 210 | + it('función getPrecioCondicionById llama a ruta correcta', function() { | |
| 211 | + | |
| 212 | + //arrange | |
| 213 | + var result; | |
| 214 | + var fakeParam = 1; | |
| 215 | + var respond = 'test'; | |
| 216 | + httpBackend.expectGET('localhost/precio-condicion/' + fakeParam).respond(respond); | |
| 217 | + | |
| 218 | + //act | |
| 219 | + servicio.getPrecioCondicionById(fakeParam).then(function(res) { | |
| 220 | + result = res.data; | |
| 221 | + }); | |
| 222 | + httpBackend.flush(); | |
| 223 | + | |
| 224 | + //assert | |
| 225 | + expect(result).toEqual(respond); | |
| 226 | + }); | |
| 227 | + | |
| 228 | + it('función getPlazoPagoByPrecioCondicion llama a ruta correcta', function() { | |
| 229 | + | |
| 230 | + //arrange | |
| 231 | + var result; | |
| 232 | + var fakeParam = 1; | |
| 233 | + var respond = 'test'; | |
| 234 | + httpBackend.expectGET('localhost/plazo-pago/precio-condicion/' + fakeParam) | |
| 235 | + .respond(respond); | |
| 236 | + | |
| 237 | + //act | |
| 238 | + servicio.getPlazoPagoByPrecioCondicion(fakeParam).then(function(res) { | |
| 239 | + result = res.data; | |
| 240 | + }); | |
| 241 | + httpBackend.flush(); | |
| 242 | + | |
| 243 | + //assert | |
| 244 | + expect(result).toEqual(respond); | |
| 245 | + }); | |
| 246 | + | |
| 247 | + it('función crearFlete llama a ruta correcta', function() { | |
| 248 | + | |
| 249 | + //arrange | |
| 250 | + var result; | |
| 251 | + var fakeParam = 1; | |
| 252 | + var respond = 'test'; | |
| 253 | + httpBackend.expectPOST('localhost/flete', {flete: fakeParam}).respond(respond); | |
| 254 | + | |
| 255 | + //act | |
| 256 | + servicio.crearFlete(fakeParam).then(function(res) { | |
| 257 | + result = res.data; | |
| 258 | + }); | |
| 259 | + httpBackend.flush(); | |
| 260 | + | |
| 261 | + //assert | |
| 262 | + expect(result).toEqual(respond); | |
| 263 | + }); | |
| 264 | + | |
| 265 | + it('función crearPlazosParaRemito llama a ruta correcta', function() { | |
| 266 | + | |
| 267 | + //arrange | |
| 268 | + var result; | |
| 269 | + var fakeParam = 1; | |
| 270 | + var respond = 'test'; | |
| 271 | + httpBackend.expectPOST('localhost/plazo-pago/remito', fakeParam).respond(respond); | |
| 272 | + | |
| 273 | + //act | |
| 274 | + servicio.crearPlazosParaRemito(fakeParam).then(function(res) { | |
| 275 | + result = res.data; | |
| 276 | + }); | |
| 277 | + httpBackend.flush(); | |
| 278 | + | |
| 279 | + //assert | |
| 280 | + expect(result).toEqual(respond); | |
| 281 | + }); | |
| 282 | + | |
| 283 | + it('función getCotizacionByIdMoneda llama a ruta correcta', function() { | |
| 284 | + | |
| 285 | + //arrange | |
| 286 | + var result; | |
| 287 | + var fakeParam = 1; | |
| 288 | + var respond = 'test'; | |
| 289 | + httpBackend.expectGET('localhost/moneda/' + fakeParam).respond(respond); | |
| 290 | + | |
| 291 | + //act | |
| 292 | + servicio.getCotizacionByIdMoneda(fakeParam).then(function(res) { | |
| 293 | + result = res.data; | |
| 294 | + }); | |
| 295 | + httpBackend.flush(); | |
| 296 | + | |
| 297 | + //assert | |
| 298 | + expect(result).toEqual(respond); | |
| 299 | + }); | |
| 300 | + | |
| 301 | + it('función crearEstadoParaRemito llama a ruta correcta', function() { | |
| 302 | + | |
| 303 | + //arrange | |
| 304 | + var result; | |
| 305 | + var fakeParam = 1; | |
| 306 | + var respond = 'test'; | |
| 307 | + httpBackend.expectPOST('localhost/estado', { estado: fakeParam }).respond(respond); | |
| 308 | + | |
| 309 | + //act | |
| 310 | + servicio.crearEstadoParaRemito(fakeParam).then(function(res) { | |
| 311 | + result = res.data; | |
| 312 | + }); | |
| 313 | + httpBackend.flush(); | |
| 314 | + | |
| 315 | + //assert | |
| 316 | + expect(result).toEqual(respond); | |
| 317 | + }); | |
| 318 | + | |
| 319 | + it('función getNumeroRemito llama a ruta correcta', function() { | |
| 320 | + | |
| 321 | + //arrange | |
| 322 | + var result; | |
| 323 | + var respond = 'test'; | |
| 324 | + httpBackend.expectGET('localhost/remito/numero-siguiente').respond(respond); | |
| 325 | + | |
| 326 | + //act | |
| 327 | + servicio.getNumeroRemito().then(function(res) { | |
| 328 | + result = res.data; | |
| 329 | + }); | |
| 330 | + httpBackend.flush(); | |
| 331 | + | |
| 332 | + //assert | |
| 333 | + expect(result).toEqual(respond); | |
| 334 | + }); | |
| 335 | + | |
| 336 | + it('función imprimirRemitoByIdRemito llama a ruta correcta', function() { | |
| 337 | + | |
| 338 | + //arrange | |
| 339 | + var result; | |
| 340 | + var fakeParam = 1; | |
| 341 | + var respond = new Blob(['test']); | |
| 342 | + httpBackend.expectGET('localhost/remito/comprobante/' + fakeParam) | |
| 343 | + .respond(respond); | |
| 344 | + | |
| 345 | + //act | |
| 346 | + servicio.imprimirRemitoByIdRemito(fakeParam).then(function(res) { | |
| 347 | + result = res.data; | |
| 348 | + }); | |
| 349 | + httpBackend.flush(); | |
| 350 | + | |
| 351 | + //assert | |
| 352 | + expect(result).toEqual(respond); | |
| 353 | + }); | |
| 354 | + | |
| 355 | + it('función getPuntosDescargaByClienDom llama a ruta correcta', function() { | |
| 356 | + | |
| 357 | + //arrange | |
| 358 | + var result; | |
| 359 | + var fakeParam = 1; | |
| 360 | + var respond = 'test'; | |
| 361 | + httpBackend.expectGET('localhost/punto-descarga/' + fakeParam + '/' + fakeParam) | |
| 362 | + .respond(respond); | |
| 363 | + | |
| 364 | + //act | |
| 365 | + servicio.getPuntosDescargaByClienDom(fakeParam, fakeParam).then(function(res) { | |
| 366 | + result = res.data; | |
| 367 | + }); | |
| 368 | + httpBackend.flush(); | |
| 369 | + | |
| 370 | + //assert | |
| 371 | + expect(result).toEqual(respond); | |
| 372 | + }); | |
| 373 | + | |
| 374 | + it('función enviarCorreo llama a ruta correcta', function() { | |
| 375 | + | |
| 376 | + //arrange | |
| 377 | + var result; | |
| 378 | + var fakeParam = 1; | |
| 379 | + var respond = 'test'; | |
| 380 | + httpBackend.expectPOST('localhost/remito/mail', fakeParam) | |
| 381 | + .respond(respond); | |
| 382 | + | |
| 383 | + //act | |
| 384 | + servicio.enviarCorreo(fakeParam).then(function(res) { | |
| 385 | + result = res.data; | |
| 386 | + }); | |
| 387 | + httpBackend.flush(); | |
| 388 | + | |
| 389 | + //assert | |
| 390 | + expect(result).toEqual(respond); | |
| 391 | + }); | |
| 392 | + }); | |
| 393 | +}); |
src/js/app.js
src/js/controller.js
| ... | ... | @@ -83,7 +83,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 83 | 83 | $scope.inicial = angular.copy($scope.remito); |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - $scope.$watch('remito', function(newValue, oldValue) { | |
| 86 | + $scope.$watch('remito', function(newValue) { | |
| 87 | 87 | focaBotoneraLateralService.setPausarData({ |
| 88 | 88 | label: 'remito', |
| 89 | 89 | val: newValue |
| ... | ... | @@ -239,7 +239,9 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 239 | 239 | } else if (!$scope.remito.proveedor) { |
| 240 | 240 | focaModalService.alert('Ingrese Proveedor'); |
| 241 | 241 | return; |
| 242 | - } else if (!$scope.remito.cotizacion.moneda.id && !$scope.remito.cotizacion.moneda.ID) { | |
| 242 | + } else if (!$scope.remito.cotizacion.moneda.id && | |
| 243 | + !$scope.remito.cotizacion.moneda.ID) | |
| 244 | + { | |
| 243 | 245 | focaModalService.alert('Ingrese Moneda'); |
| 244 | 246 | return; |
| 245 | 247 | } else if (!$scope.remito.cotizacion.ID) { |
| ... | ... | @@ -699,9 +701,11 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 699 | 701 | return { |
| 700 | 702 | flete: $scope.remito.flete ? '1' : |
| 701 | 703 | ($scope.remito.fob ? 'FOB' : |
| 702 | - ($scope.remito.flete === undefined ? null : '0')), | |
| 704 | + ($scope.remito.flete === undefined ? | |
| 705 | + null : '0')), | |
| 703 | 706 | bomba: $scope.remito.bomba ? '1' : |
| 704 | - ($scope.remito.bomba === undefined ? null : '0'), | |
| 707 | + ($scope.remito.bomba === undefined ? | |
| 708 | + null : '0'), | |
| 705 | 709 | kilometros: $scope.remito.kilometros |
| 706 | 710 | }; |
| 707 | 711 | } |
test.html
| ... | ... | @@ -0,0 +1,22 @@ |
| 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 | + | |
| 18 | + <script type="text/javascript" src="spec/controllerSpec.js"></script> | |
| 19 | + <script type="text/javascript" src="spec/serviceSpec.js"></script> | |
| 20 | + <script type="text/javascript" src="spec/routeSpec.js"></script> | |
| 21 | + </body> | |
| 22 | +</html> |