Commit 5b9112a293fb3d8fe8f5213db2e0c01ef84ac9be

Authored by Luigi
1 parent 72c0063c55
Exists in master and in 2 other branches develop, lab

Cambio en comisión - Arreglo en el Test

Showing 2 changed files with 118 additions and 21 deletions   Show diff stats
spec/controllerSpec.js
... ... @@ -23,6 +23,7 @@ describe('Controladores abm vendedor cobrador', function() {
23 23 $scope: {},
24 24 focaAbmVendedorCobradorService: {},
25 25 $location: {},
  26 + $localStorage: {},
26 27 $filter: {},
27 28 focaBotoneraLateralService: focaBotoneraLateralService,
28 29 focaModalService: {}
... ... @@ -41,6 +42,7 @@ describe('Controladores abm vendedor cobrador', function() {
41 42 $scope: scope,
42 43 focaAbmVendedorCobradorService: {},
43 44 $location: $location,
  45 + $localStorage: {},
44 46 $filter: {},
45 47 focaBotoneraLateralService: focaBotoneraLateralService,
46 48 focaModalService: {}
... ... @@ -66,6 +68,7 @@ describe('Controladores abm vendedor cobrador', function() {
66 68 $scope: scope,
67 69 focaAbmVendedorCobradorService: {},
68 70 $location: $location,
  71 + $localStorage: {},
69 72 $filter: {},
70 73 focaBotoneraLateralService: focaBotoneraLateralService,
71 74 focaModalService: focaModalService
... ... @@ -96,6 +99,7 @@ describe('Controladores abm vendedor cobrador', function() {
96 99 $scope: scope,
97 100 focaAbmVendedorCobradorService: focaAbmVendedorCobradorService,
98 101 $location: $location,
  102 + $localStorage: {},
99 103 $filter: {},
100 104 focaBotoneraLateralService: focaBotoneraLateralService,
101 105 focaModalService: focaModalService
... ... @@ -126,6 +130,7 @@ describe('Controladores abm vendedor cobrador', function() {
126 130 $scope: scope,
127 131 focaAbmVendedorCobradorService: {},
128 132 $location: {},
  133 + $localStorage: {},
129 134 $filter: {},
130 135 focaBotoneraLateralService: focaBotoneraLateralService,
131 136 focaModalService: {}
... ... @@ -150,6 +155,7 @@ describe('Controladores abm vendedor cobrador', function() {
150 155 $scope: scope,
151 156 focaAbmVendedorCobradorService: focaAbmVendedorCobradorService,
152 157 $location: {},
  158 + $localStorage: {},
153 159 $filter: {},
154 160 focaBotoneraLateralService: focaBotoneraLateralService,
155 161 focaModalService: {}
... ... @@ -175,6 +181,7 @@ describe('Controladores abm vendedor cobrador', function() {
175 181 $scope: scope,
176 182 focaAbmVendedorCobradorService: focaAbmVendedorCobradorService,
177 183 $location: {},
  184 + $localStorage: {},
178 185 $filter: {},
179 186 focaBotoneraLateralService: focaBotoneraLateralService,
180 187 focaModalService: {}
... ... @@ -210,7 +217,9 @@ describe('Controladores abm vendedor cobrador', function() {
210 217  
211 218 //act
212 219 var controlador = $controller('focaAbmVendedorCobradorController', {
213   - $scope: {},
  220 + $scope: {
  221 + $watch: function() {}
  222 + },
214 223 focaAbmVendedorCobradorService: {
215 224 getCodigoSiguiente: function() {
216 225 return {
... ... @@ -228,7 +237,10 @@ describe('Controladores abm vendedor cobrador', function() {
228 237 $timeout: timeout,
229 238 $uibModal: {},
230 239 $location: {},
231   - focaModalService: {}
  240 + $localStorage: {},
  241 + focaModalService: {
  242 +
  243 + }
232 244 });
233 245  
234 246 //assert
... ... @@ -237,7 +249,10 @@ describe('Controladores abm vendedor cobrador', function() {
237 249  
238 250 it('la función $scope.guardar llama a guardaVendedorCobrador del servicio', function() {
239 251 //arrange
240   - var scope= {};
  252 + var scope = {
  253 + $watch: function() {},
  254 +
  255 + };
241 256 var focaAbmVendedorCobradorService = {
242 257 getCodigoSiguiente: function() {
243 258 return {
... ... @@ -252,14 +267,18 @@ describe('Controladores abm vendedor cobrador', function() {
252 267 guardarVendedorCobrador: function() { }
253 268 };
254 269 $controller('focaAbmVendedorCobradorController', {
255   - $scope: scope,
  270 + $scope: scope,
256 271 focaAbmVendedorCobradorService: focaAbmVendedorCobradorService,
257 272 $routeParams: {},
258 273 focaBotoneraLateralService: {},
259 274 $timeout: timeout,
260 275 $uibModal: {},
261 276 $location: {},
262   - focaModalService: {}
  277 + $localStorage: {},
  278 + guardarVendedorCobrador: {},
  279 + focaModalService: {
  280 + alert: function() {}
  281 + }
263 282 });
264 283 var responseFake = {
265 284 then: function() {
... ... @@ -268,6 +287,19 @@ describe('Controladores abm vendedor cobrador', function() {
268 287 };
269 288 }
270 289 };
  290 + scope.vendedorCobrador = {
  291 + NOM: true,
  292 + domicilio: true,
  293 + codigoPostal: true,
  294 + dni: true,
  295 + rol: true,
  296 + provincia: {
  297 + NOMBRE: true
  298 + },
  299 + localidad: {
  300 + NOMBRE: true
  301 + },
  302 + };
271 303  
272 304 //act
273 305 spyOn(focaAbmVendedorCobradorService, 'guardarVendedorCobrador')
... ... @@ -278,13 +310,15 @@ describe('Controladores abm vendedor cobrador', function() {
278 310 expect(focaAbmVendedorCobradorService.guardarVendedorCobrador).toHaveBeenCalled();
279 311 });
280 312  
281   - it('la función $scope.guardar llama a guardaVendedorCobrador y edicion true' +
  313 + it('la función $scope.guardar llama a guardaVendedorCobrador y edicion true ' +
282 314 'llama a $location.path', function(done)
283 315 {
284 316 inject(function($location) {
285 317  
286 318 //arrange
287   - var scope= {};
  319 + var scope= {
  320 + $watch: function(){},
  321 + };
288 322 var focaAbmVendedorCobradorService = {
289 323 getCodigoSiguiente: function() {
290 324 return {
... ... @@ -306,10 +340,27 @@ describe('Controladores abm vendedor cobrador', function() {
306 340 $timeout: timeout,
307 341 $uibModal: {},
308 342 $location: $location,
309   - focaModalService: {}
  343 + $localStorage: {},
  344 + focaModalService: {
  345 + alert: function() {}
  346 + }
310 347 });
311 348 var promiseFake = Promise.resolve(true, false);
312 349  
  350 + scope.vendedorCobrador = {
  351 + NOM: true,
  352 + domicilio: true,
  353 + codigoPostal: true,
  354 + dni: true,
  355 + rol: true,
  356 + provincia: {
  357 + NOMBRE: true
  358 + },
  359 + localidad: {
  360 + NOMBRE: true
  361 + },
  362 + };
  363 +
313 364 //act
314 365 spyOn(focaAbmVendedorCobradorService, 'guardarVendedorCobrador')
315 366 .and.returnValue(promiseFake);
... ... @@ -324,11 +375,13 @@ describe('Controladores abm vendedor cobrador', function() {
324 375 });
325 376 });
326 377  
327   - it('la función $scope.guardar llama a guardaVendedorCobrador y scope.edicion false' +
  378 + it('la función $scope.guardar llama a guardaVendedorCobrador y scope.edicion false ' +
328 379 'llama a scope.cambiarContraseña', function(done)
329 380 {
330 381 //arrange
331   - var scope= {};
  382 + var scope= {
  383 + $watch: function() {}
  384 + };
332 385 var focaAbmVendedorCobradorService = {
333 386 getCodigoSiguiente: function() {
334 387 return {
... ... @@ -350,10 +403,27 @@ describe('Controladores abm vendedor cobrador', function() {
350 403 $timeout: timeout,
351 404 $uibModal: {},
352 405 $location: {},
353   - focaModalService: {}
  406 + $localStorage: {},
  407 + focaModalService: {
  408 + alert: function(){}
  409 + }
354 410 });
355 411 var promiseFake = Promise.resolve(true, false);
356 412  
  413 + scope.vendedorCobrador = {
  414 + NOM: true,
  415 + domicilio: true,
  416 + codigoPostal: true,
  417 + dni: true,
  418 + rol: true,
  419 + provincia: {
  420 + NOMBRE: true
  421 + },
  422 + localidad: {
  423 + NOMBRE: true
  424 + },
  425 + };
  426 +
357 427 //act
358 428 spyOn(focaAbmVendedorCobradorService, 'guardarVendedorCobrador')
359 429 .and.returnValue(promiseFake);
... ... @@ -369,10 +439,12 @@ describe('Controladores abm vendedor cobrador', function() {
369 439 });
370 440  
371 441 it('la función $scope.guardar llama a guardaVendedorCobrador y llama foca modal alert' +
372   - 'cuando la promsa es rechazada y el error es 409', function(done)
  442 + 'cuando la promesa es rechazada y el error es 409', function(done)
373 443 {
374 444 //arrange
375   - var scope= {};
  445 + var scope= {
  446 + $watch: function() {}
  447 + };
376 448 var focaAbmVendedorCobradorService = {
377 449 getCodigoSiguiente: function() {
378 450 return {
... ... @@ -397,6 +469,7 @@ describe('Controladores abm vendedor cobrador', function() {
397 469 $timeout: timeout,
398 470 $uibModal: {},
399 471 $location: {},
  472 + $localStorage: {},
400 473 focaModalService: focaModalService
401 474 });
402 475 var promiseFake = Promise.reject({ status: 409 });
... ... @@ -418,7 +491,9 @@ describe('Controladores abm vendedor cobrador', function() {
418 491  
419 492 it('la función $scope.seleccionarProvincia llama a foca Modal', function() {
420 493 //arrange
421   - var scope= {};
  494 + var scope= {
  495 + $watch: function() {}
  496 + };
422 497 var focaAbmVendedorCobradorService = {
423 498 getCodigoSiguiente: function() {
424 499 return {
... ... @@ -442,6 +517,7 @@ describe('Controladores abm vendedor cobrador', function() {
442 517 $timeout: timeout,
443 518 $uibModal: {},
444 519 $location: {},
  520 + $localStorage: {},
445 521 focaModalService: focaModalService
446 522 });
447 523  
... ... @@ -455,7 +531,9 @@ describe('Controladores abm vendedor cobrador', function() {
455 531  
456 532 it('función $scope.seleccionarLocalidad llama foca alert si no hay provincia', function() {
457 533 //arrange
458   - var scope= {};
  534 + var scope = {
  535 + $watch: function() {}
  536 + };
459 537 var focaAbmVendedorCobradorService = {
460 538 getCodigoSiguiente: function() {
461 539 return {
... ... @@ -479,6 +557,7 @@ describe('Controladores abm vendedor cobrador', function() {
479 557 $timeout: timeout,
480 558 $uibModal: {},
481 559 $location: {},
  560 + $localStorage: {},
482 561 focaModalService: focaModalService
483 562 });
484 563  
... ... @@ -493,7 +572,9 @@ describe('Controladores abm vendedor cobrador', function() {
493 572  
494 573 it('función $scope.seleccionarLocalidad llama foca modal', function() {
495 574 //arrange
496   - var scope= {};
  575 + var scope= {
  576 + $watch: function() {}
  577 + };
497 578 var focaAbmVendedorCobradorService = {
498 579 getCodigoSiguiente: function() {
499 580 return {
... ... @@ -517,6 +598,7 @@ describe('Controladores abm vendedor cobrador', function() {
517 598 $timeout: timeout,
518 599 $uibModal: {},
519 600 $location: {},
  601 + $localStorage: {},
520 602 focaModalService: focaModalService
521 603 });
522 604  
... ... @@ -533,7 +615,9 @@ describe('Controladores abm vendedor cobrador', function() {
533 615  
534 616 inject(function($location) {
535 617 //arrange
536   - var scope = {};
  618 + var scope = {
  619 + $watch: function() {}
  620 + };
537 621 $controller('focaAbmVendedorCobradorController', {
538 622 $scope: scope,
539 623 focaAbmVendedorCobradorService: {
... ... @@ -553,6 +637,7 @@ describe('Controladores abm vendedor cobrador', function() {
553 637 $timeout: timeout,
554 638 $uibModal: {},
555 639 $location: $location,
  640 + $localStorage: {},
556 641 focaModalService: {}
557 642 });
558 643  
... ... @@ -570,7 +655,9 @@ describe('Controladores abm vendedor cobrador', function() {
570 655 it('la funcion scope.next suma uno a scope.focused', function() {
571 656  
572 657 //arrange
573   - var scope = {};
  658 + var scope = {
  659 + $watch: function() {}
  660 + };
574 661 $controller('focaAbmVendedorCobradorController', {
575 662 $scope: scope,
576 663 focaAbmVendedorCobradorService: {
... ... @@ -590,6 +677,7 @@ describe('Controladores abm vendedor cobrador', function() {
590 677 $timeout: timeout,
591 678 $uibModal: {},
592 679 $location: {},
  680 + $localStorage: {},
593 681 focaModalService: {}
594 682 });
595 683  
... ... @@ -604,7 +692,9 @@ describe('Controladores abm vendedor cobrador', function() {
604 692 it('la funcion scope.cambiarPassword abre modal', function() {
605 693  
606 694 //arrange
607   - var scope = {};
  695 + var scope = {
  696 + $watch: function() {}
  697 + };
608 698 var uibModal = {
609 699 open: function() { }
610 700 };
... ... @@ -627,6 +717,7 @@ describe('Controladores abm vendedor cobrador', function() {
627 717 $timeout: timeout,
628 718 $uibModal: uibModal,
629 719 $location: {},
  720 + $localStorage: {},
630 721 focaModalService: {}
631 722 });
632 723 var responseFake = {
... ... @@ -649,7 +740,9 @@ describe('Controladores abm vendedor cobrador', function() {
649 740 inject(function($location) {
650 741  
651 742 //arrange
652   - var scope = {};
  743 + var scope = {
  744 + $watch: function() {}
  745 + };
653 746 var uibModal = {
654 747 open: function() { }
655 748 };
... ... @@ -672,6 +765,7 @@ describe('Controladores abm vendedor cobrador', function() {
672 765 $timeout: timeout,
673 766 $uibModal: uibModal,
674 767 $location: $location,
  768 + $localStorage: {},
675 769 focaModalService: {}
676 770 });
677 771 var responseFake = {
src/js/controllerItem.js
... ... @@ -86,7 +86,10 @@ angular.module('focaAbmVendedorCobrador')
86 86 } else if (!$scope.vendedorCobrador.localidad.NOMBRE) {
87 87 focaModalService.alert('Seleccione una Localidad');
88 88 return;
89   - }
  89 + } else if ($scope.vendedorCobrador.comisionCobrador < 0 || $scope.vendedorCobrador.comisionVendedor < 0){
  90 + focaModalService.alert('Ingrese un numero superior a 0 en porcentaje de comision');
  91 + return;
  92 + }
90 93  
91 94 if ($scope.guardado) {
92 95 $scope.cambiarPassword();