Commit a24ce94ee3bc70f048b9b44353526b65d60a814b
1 parent
2ed3c8ad38
Exists in
master
and in
1 other branch
ok tests
Showing
3 changed files
with
43 additions
and
244 deletions
Show diff stats
spec/controllerSpec.js
| ... | ... | @@ -652,58 +652,6 @@ describe('Controladores módulo crear nota de pedido', function() { |
| 652 | 652 | }); |
| 653 | 653 | }); |
| 654 | 654 | |
| 655 | - it('función seleccionarCliente abre alerta cuando no se elije vendedor', function() { | |
| 656 | - //arrange | |
| 657 | - var scope = { | |
| 658 | - $watch: function() { }, | |
| 659 | - $broadcast: function() { } | |
| 660 | - }; | |
| 661 | - var focaModalService = { | |
| 662 | - alert: function() { } | |
| 663 | - }; | |
| 664 | - | |
| 665 | - $controler('notaPedidoCtrl', { | |
| 666 | - $scope: scope, | |
| 667 | - $uibModal: {}, | |
| 668 | - $location: {}, | |
| 669 | - $filter: filter, | |
| 670 | - $timeout: timeout, | |
| 671 | - crearNotaPedidoService: { | |
| 672 | - getNumeroNotaPedido: function() { | |
| 673 | - return { | |
| 674 | - then: function() { } | |
| 675 | - }; | |
| 676 | - }, | |
| 677 | - getBotonera: function() { }, | |
| 678 | - getCotizacionByIdMoneda: function() { | |
| 679 | - return { | |
| 680 | - then: function() { } | |
| 681 | - }; | |
| 682 | - } | |
| 683 | - }, | |
| 684 | - focaBotoneraLateralService: {}, | |
| 685 | - focaModalService: focaModalService, | |
| 686 | - notaPedidoBusinessService: {}, | |
| 687 | - $rootScope: { | |
| 688 | - $on: function() { } | |
| 689 | - }, | |
| 690 | - focaSeguimientoService: {}, | |
| 691 | - APP: {}, | |
| 692 | - focaLoginService: {}, | |
| 693 | - $localStorage: {} | |
| 694 | - }); | |
| 695 | - scope.notaPedido = { | |
| 696 | - vendedor: { NUM: false } | |
| 697 | - }; | |
| 698 | - | |
| 699 | - //act | |
| 700 | - spyOn(focaModalService, 'alert'); | |
| 701 | - scope.seleccionarCliente(); | |
| 702 | - | |
| 703 | - //assert | |
| 704 | - expect(focaModalService.alert).toHaveBeenCalledWith('Primero seleccione un vendedor'); | |
| 705 | - }); | |
| 706 | - | |
| 707 | 655 | it('función seleccionarCliente abre modal', function() { |
| 708 | 656 | //arrange |
| 709 | 657 | var scope = { |
| ... | ... | @@ -731,17 +679,34 @@ describe('Controladores módulo crear nota de pedido', function() { |
| 731 | 679 | return { |
| 732 | 680 | then: function() { } |
| 733 | 681 | }; |
| 682 | + }, | |
| 683 | + getVendedorById: function() { | |
| 684 | + return { | |
| 685 | + then: function() { } | |
| 686 | + }; | |
| 734 | 687 | } |
| 735 | 688 | }, |
| 736 | 689 | focaBotoneraLateralService: {}, |
| 737 | - focaModalService: {}, | |
| 690 | + focaModalService: { | |
| 691 | + modal: function() { | |
| 692 | + return { | |
| 693 | + then: function() {} | |
| 694 | + }; | |
| 695 | + } | |
| 696 | + }, | |
| 738 | 697 | notaPedidoBusinessService: {}, |
| 739 | 698 | $rootScope: { |
| 740 | 699 | $on: function() { } |
| 741 | 700 | }, |
| 742 | 701 | focaSeguimientoService: {}, |
| 743 | - APP: {}, | |
| 744 | - focaLoginService: {}, | |
| 702 | + APP: 'distribuidor', | |
| 703 | + focaLoginService: { | |
| 704 | + getLoginData: function() { | |
| 705 | + return { | |
| 706 | + vendedorCorbrador: true | |
| 707 | + } | |
| 708 | + } | |
| 709 | + }, | |
| 745 | 710 | $localStorage: {} |
| 746 | 711 | }); |
| 747 | 712 | scope.notaPedido = { |
| ... | ... | @@ -763,7 +728,9 @@ describe('Controladores módulo crear nota de pedido', function() { |
| 763 | 728 | //arrange |
| 764 | 729 | var scope = { |
| 765 | 730 | $watch: function() { }, |
| 766 | - $broadcast: function() { } | |
| 731 | + $broadcast: function() { }, | |
| 732 | + seleccionarVendedor: function() { }, | |
| 733 | + notaPedido: {} | |
| 767 | 734 | }; |
| 768 | 735 | var uibModal = { |
| 769 | 736 | open: function() { } |
| ... | ... | @@ -786,17 +753,34 @@ describe('Controladores módulo crear nota de pedido', function() { |
| 786 | 753 | return { |
| 787 | 754 | then: function() { } |
| 788 | 755 | }; |
| 756 | + }, | |
| 757 | + getVendedorById : function() { | |
| 758 | + return { | |
| 759 | + then: function() { } | |
| 760 | + } | |
| 789 | 761 | } |
| 790 | 762 | }, |
| 791 | 763 | focaBotoneraLateralService: {}, |
| 792 | - focaModalService: {}, | |
| 764 | + focaModalService: { | |
| 765 | + modal: function() { | |
| 766 | + return { | |
| 767 | + then: function() { } | |
| 768 | + }; | |
| 769 | + } | |
| 770 | + }, | |
| 793 | 771 | notaPedidoBusinessService: {}, |
| 794 | 772 | $rootScope: { |
| 795 | 773 | $on: function() { } |
| 796 | 774 | }, |
| 797 | 775 | focaSeguimientoService: {}, |
| 798 | - APP: {}, | |
| 799 | - focaLoginService: {}, | |
| 776 | + APP: 'distribuidor', | |
| 777 | + focaLoginService: { | |
| 778 | + getLoginData: function() { | |
| 779 | + return { | |
| 780 | + vendedorCorbrador: true | |
| 781 | + }; | |
| 782 | + } | |
| 783 | + }, | |
| 800 | 784 | $localStorage: {} |
| 801 | 785 | }); |
| 802 | 786 | scope.idLista = true; |
| ... | ... | @@ -1163,126 +1147,6 @@ describe('Controladores módulo crear nota de pedido', function() { |
| 1163 | 1147 | }); |
| 1164 | 1148 | }); |
| 1165 | 1149 | |
| 1166 | - it('función seleccionarFlete abre modal', function() { | |
| 1167 | - | |
| 1168 | - //arrange | |
| 1169 | - var scope = { | |
| 1170 | - $watch: function() { }, | |
| 1171 | - $broadcast: function() { } | |
| 1172 | - }; | |
| 1173 | - var uibModal = { | |
| 1174 | - open: function() { } | |
| 1175 | - }; | |
| 1176 | - | |
| 1177 | - $controler('notaPedidoCtrl', { | |
| 1178 | - $scope: scope, | |
| 1179 | - $uibModal: uibModal, | |
| 1180 | - $location: {}, | |
| 1181 | - $filter: filter, | |
| 1182 | - $timeout: timeout, | |
| 1183 | - crearNotaPedidoService: { | |
| 1184 | - getNumeroNotaPedido: function() { | |
| 1185 | - return { | |
| 1186 | - then: function() { } | |
| 1187 | - }; | |
| 1188 | - }, | |
| 1189 | - getBotonera: function() { }, | |
| 1190 | - getCotizacionByIdMoneda: function() { | |
| 1191 | - return { | |
| 1192 | - then: function() { } | |
| 1193 | - }; | |
| 1194 | - } | |
| 1195 | - }, | |
| 1196 | - focaBotoneraLateralService: {}, | |
| 1197 | - focaModalService: {}, | |
| 1198 | - notaPedidoBusinessService: {}, | |
| 1199 | - $rootScope: { | |
| 1200 | - $on: function() { } | |
| 1201 | - }, | |
| 1202 | - focaSeguimientoService: {}, | |
| 1203 | - APP: {}, | |
| 1204 | - focaLoginService: {}, | |
| 1205 | - $localStorage: {} | |
| 1206 | - }); | |
| 1207 | - | |
| 1208 | - scope.notaPedido = {}; | |
| 1209 | - | |
| 1210 | - var respuesta = { result: {then: function() { } } }; | |
| 1211 | - | |
| 1212 | - //act | |
| 1213 | - spyOn(uibModal, 'open').and.returnValue(respuesta); | |
| 1214 | - scope.seleccionarFlete(); | |
| 1215 | - | |
| 1216 | - //assert | |
| 1217 | - expect(uibModal.open).toHaveBeenCalled(); | |
| 1218 | - }); | |
| 1219 | - | |
| 1220 | - it('función seleccionarFlete setea flete y cabecera', function(done) { | |
| 1221 | - | |
| 1222 | - //arrange | |
| 1223 | - var scope = { | |
| 1224 | - $watch: function() { }, | |
| 1225 | - $broadcast: function() { } | |
| 1226 | - }; | |
| 1227 | - var uibModal = { | |
| 1228 | - open: function() { } | |
| 1229 | - }; | |
| 1230 | - | |
| 1231 | - $controler('notaPedidoCtrl', { | |
| 1232 | - $scope: scope, | |
| 1233 | - $uibModal: uibModal, | |
| 1234 | - $location: {}, | |
| 1235 | - $filter: filter, | |
| 1236 | - $timeout: timeout, | |
| 1237 | - crearNotaPedidoService: { | |
| 1238 | - getNumeroNotaPedido: function() { | |
| 1239 | - return { | |
| 1240 | - then: function() { } | |
| 1241 | - }; | |
| 1242 | - }, | |
| 1243 | - getBotonera: function() { }, | |
| 1244 | - getCotizacionByIdMoneda: function() { | |
| 1245 | - return { | |
| 1246 | - then: function() { } | |
| 1247 | - }; | |
| 1248 | - } | |
| 1249 | - }, | |
| 1250 | - focaBotoneraLateralService: {}, | |
| 1251 | - focaModalService: {}, | |
| 1252 | - notaPedidoBusinessService: {}, | |
| 1253 | - $rootScope: { | |
| 1254 | - $on: function() { } | |
| 1255 | - }, | |
| 1256 | - focaSeguimientoService: {}, | |
| 1257 | - APP: {}, | |
| 1258 | - focaLoginService: {}, | |
| 1259 | - $localStorage: {} | |
| 1260 | - }); | |
| 1261 | - scope.idLista = true; | |
| 1262 | - scope.notaPedido = { | |
| 1263 | - vendedor: { NUM: true } | |
| 1264 | - }; | |
| 1265 | - var respuesta = { flete: 1, FOB: 2, bomba: 3, kilometros: 4 }; | |
| 1266 | - var promesaRespuesta = { result: Promise.resolve(respuesta) }; | |
| 1267 | - scope.$broadcast = function() { }; | |
| 1268 | - | |
| 1269 | - //act | |
| 1270 | - spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); | |
| 1271 | - spyOn(scope, '$broadcast'); | |
| 1272 | - scope.seleccionarFlete(); | |
| 1273 | - | |
| 1274 | - //assert | |
| 1275 | - | |
| 1276 | - promesaRespuesta.result.then(function() { | |
| 1277 | - expect(scope.notaPedido.flete).toEqual(respuesta.flete); | |
| 1278 | - expect(scope.notaPedido.fob).toEqual(respuesta.FOB); | |
| 1279 | - expect(scope.notaPedido.bomba).toEqual(respuesta.bomba); | |
| 1280 | - expect(scope.notaPedido.kilometros).toEqual(respuesta.kilometros); | |
| 1281 | - expect(scope.$broadcast).toHaveBeenCalled(); | |
| 1282 | - done(); | |
| 1283 | - }); | |
| 1284 | - }); | |
| 1285 | - | |
| 1286 | 1150 | it('función seleccionarMoneda abre modal', function() { |
| 1287 | 1151 | //arrange |
| 1288 | 1152 | var scope = { |
spec/controllerSpecCrearPedido.js
| ... | ... | @@ -64,63 +64,6 @@ describe('Controladores módulo crear nota de pedido', function() { |
| 64 | 64 | expect(typeof controlador).toEqual('object'); |
| 65 | 65 | }); |
| 66 | 66 | |
| 67 | - it('la funcion $scope.crearNotaPedido muestra alerta cuando vendedor es null', function() { | |
| 68 | - | |
| 69 | - //arrange | |
| 70 | - var scope = { | |
| 71 | - $watch: function() { }, | |
| 72 | - $broadcast: function() {} | |
| 73 | - }; | |
| 74 | - var focaModalService = { | |
| 75 | - alert: function() { } | |
| 76 | - }; | |
| 77 | - | |
| 78 | - $controler('notaPedidoCtrl', { | |
| 79 | - $scope: scope, | |
| 80 | - $uibModal: {}, | |
| 81 | - $location: {}, | |
| 82 | - $filter: filter, | |
| 83 | - $timeout: timeout, | |
| 84 | - crearNotaPedidoService: { | |
| 85 | - getNumeroNotaPedido: function() { | |
| 86 | - return { | |
| 87 | - then: function() { } | |
| 88 | - }; | |
| 89 | - }, | |
| 90 | - getBotonera: function() { }, | |
| 91 | - getCotizacionByIdMoneda: function() { | |
| 92 | - return { | |
| 93 | - then: function() {} | |
| 94 | - }; | |
| 95 | - } | |
| 96 | - }, | |
| 97 | - focaBotoneraLateralService: {}, | |
| 98 | - focaModalService: focaModalService, | |
| 99 | - notaPedidoBusinessService: {}, | |
| 100 | - $rootScope: { | |
| 101 | - $on: function() { } | |
| 102 | - }, | |
| 103 | - focaSeguimientoService: {}, | |
| 104 | - APP: {}, | |
| 105 | - focaLoginService: {}, | |
| 106 | - $localStorage: {}, | |
| 107 | - $watch: function() { }, | |
| 108 | - $broadcast: function() {} | |
| 109 | - }); | |
| 110 | - | |
| 111 | - //act | |
| 112 | - scope.notaPedido = { | |
| 113 | - vendedor: { | |
| 114 | - id: null | |
| 115 | - } | |
| 116 | - }; | |
| 117 | - spyOn(focaModalService, 'alert'); | |
| 118 | - scope.crearNotaPedido(); | |
| 119 | - | |
| 120 | - //expect | |
| 121 | - expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Vendedor'); | |
| 122 | - }); | |
| 123 | - | |
| 124 | 67 | it('la funcion $scope.crearNotaPedido muestra alerta cuando cliente es null', function() { |
| 125 | 68 | |
| 126 | 69 | //arrange |
src/js/controller.js
| ... | ... | @@ -443,10 +443,6 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 443 | 443 | |
| 444 | 444 | $scope.seleccionarCliente = function(ocultarVendedor) { |
| 445 | 445 | $scope.seleccionarVendedor(function() { |
| 446 | - if (!$scope.notaPedido.vendedor.NUM) { | |
| 447 | - focaModalService.alert('Primero seleccione un vendedor'); | |
| 448 | - return; | |
| 449 | - } | |
| 450 | 446 | if (validarNotaRemitada()) { |
| 451 | 447 | var modalInstance = $uibModal.open( |
| 452 | 448 | { |
| ... | ... | @@ -631,10 +627,6 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 631 | 627 | } |
| 632 | 628 | }; |
| 633 | 629 | |
| 634 | - $scope.seleccionarFlete = function() { | |
| 635 | - | |
| 636 | - }; | |
| 637 | - | |
| 638 | 630 | $scope.seleccionarMoneda = function() { |
| 639 | 631 | if(validarNotaRemitada()) { |
| 640 | 632 | var parametrosModal = { |