diff --git a/spec/controllerSpec.js b/spec/controllerSpec.js index 6fbc44a..82caee4 100644 --- a/spec/controllerSpec.js +++ b/spec/controllerSpec.js @@ -652,58 +652,6 @@ describe('Controladores módulo crear nota de pedido', function() { }); }); - it('función seleccionarCliente abre alerta cuando no se elije vendedor', function() { - //arrange - var scope = { - $watch: function() { }, - $broadcast: function() { } - }; - var focaModalService = { - alert: function() { } - }; - - $controler('notaPedidoCtrl', { - $scope: scope, - $uibModal: {}, - $location: {}, - $filter: filter, - $timeout: timeout, - crearNotaPedidoService: { - getNumeroNotaPedido: function() { - return { - then: function() { } - }; - }, - getBotonera: function() { }, - getCotizacionByIdMoneda: function() { - return { - then: function() { } - }; - } - }, - focaBotoneraLateralService: {}, - focaModalService: focaModalService, - notaPedidoBusinessService: {}, - $rootScope: { - $on: function() { } - }, - focaSeguimientoService: {}, - APP: {}, - focaLoginService: {}, - $localStorage: {} - }); - scope.notaPedido = { - vendedor: { NUM: false } - }; - - //act - spyOn(focaModalService, 'alert'); - scope.seleccionarCliente(); - - //assert - expect(focaModalService.alert).toHaveBeenCalledWith('Primero seleccione un vendedor'); - }); - it('función seleccionarCliente abre modal', function() { //arrange var scope = { @@ -731,17 +679,34 @@ describe('Controladores módulo crear nota de pedido', function() { return { then: function() { } }; + }, + getVendedorById: function() { + return { + then: function() { } + }; } }, focaBotoneraLateralService: {}, - focaModalService: {}, + focaModalService: { + modal: function() { + return { + then: function() {} + }; + } + }, notaPedidoBusinessService: {}, $rootScope: { $on: function() { } }, focaSeguimientoService: {}, - APP: {}, - focaLoginService: {}, + APP: 'distribuidor', + focaLoginService: { + getLoginData: function() { + return { + vendedorCorbrador: true + } + } + }, $localStorage: {} }); scope.notaPedido = { @@ -763,7 +728,9 @@ describe('Controladores módulo crear nota de pedido', function() { //arrange var scope = { $watch: function() { }, - $broadcast: function() { } + $broadcast: function() { }, + seleccionarVendedor: function() { }, + notaPedido: {} }; var uibModal = { open: function() { } @@ -786,17 +753,34 @@ describe('Controladores módulo crear nota de pedido', function() { return { then: function() { } }; + }, + getVendedorById : function() { + return { + then: function() { } + } } }, focaBotoneraLateralService: {}, - focaModalService: {}, + focaModalService: { + modal: function() { + return { + then: function() { } + }; + } + }, notaPedidoBusinessService: {}, $rootScope: { $on: function() { } }, focaSeguimientoService: {}, - APP: {}, - focaLoginService: {}, + APP: 'distribuidor', + focaLoginService: { + getLoginData: function() { + return { + vendedorCorbrador: true + }; + } + }, $localStorage: {} }); scope.idLista = true; @@ -1163,126 +1147,6 @@ describe('Controladores módulo crear nota de pedido', function() { }); }); - it('función seleccionarFlete abre modal', function() { - - //arrange - var scope = { - $watch: function() { }, - $broadcast: function() { } - }; - var uibModal = { - open: function() { } - }; - - $controler('notaPedidoCtrl', { - $scope: scope, - $uibModal: uibModal, - $location: {}, - $filter: filter, - $timeout: timeout, - crearNotaPedidoService: { - getNumeroNotaPedido: function() { - return { - then: function() { } - }; - }, - getBotonera: function() { }, - getCotizacionByIdMoneda: function() { - return { - then: function() { } - }; - } - }, - focaBotoneraLateralService: {}, - focaModalService: {}, - notaPedidoBusinessService: {}, - $rootScope: { - $on: function() { } - }, - focaSeguimientoService: {}, - APP: {}, - focaLoginService: {}, - $localStorage: {} - }); - - scope.notaPedido = {}; - - var respuesta = { result: {then: function() { } } }; - - //act - spyOn(uibModal, 'open').and.returnValue(respuesta); - scope.seleccionarFlete(); - - //assert - expect(uibModal.open).toHaveBeenCalled(); - }); - - it('función seleccionarFlete setea flete y cabecera', function(done) { - - //arrange - var scope = { - $watch: function() { }, - $broadcast: function() { } - }; - var uibModal = { - open: function() { } - }; - - $controler('notaPedidoCtrl', { - $scope: scope, - $uibModal: uibModal, - $location: {}, - $filter: filter, - $timeout: timeout, - crearNotaPedidoService: { - getNumeroNotaPedido: function() { - return { - then: function() { } - }; - }, - getBotonera: function() { }, - getCotizacionByIdMoneda: function() { - return { - then: function() { } - }; - } - }, - focaBotoneraLateralService: {}, - focaModalService: {}, - notaPedidoBusinessService: {}, - $rootScope: { - $on: function() { } - }, - focaSeguimientoService: {}, - APP: {}, - focaLoginService: {}, - $localStorage: {} - }); - scope.idLista = true; - scope.notaPedido = { - vendedor: { NUM: true } - }; - var respuesta = { flete: 1, FOB: 2, bomba: 3, kilometros: 4 }; - var promesaRespuesta = { result: Promise.resolve(respuesta) }; - scope.$broadcast = function() { }; - - //act - spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); - spyOn(scope, '$broadcast'); - scope.seleccionarFlete(); - - //assert - - promesaRespuesta.result.then(function() { - expect(scope.notaPedido.flete).toEqual(respuesta.flete); - expect(scope.notaPedido.fob).toEqual(respuesta.FOB); - expect(scope.notaPedido.bomba).toEqual(respuesta.bomba); - expect(scope.notaPedido.kilometros).toEqual(respuesta.kilometros); - expect(scope.$broadcast).toHaveBeenCalled(); - done(); - }); - }); - it('función seleccionarMoneda abre modal', function() { //arrange var scope = { diff --git a/spec/controllerSpecCrearPedido.js b/spec/controllerSpecCrearPedido.js index c2fba18..7eb37d8 100644 --- a/spec/controllerSpecCrearPedido.js +++ b/spec/controllerSpecCrearPedido.js @@ -64,63 +64,6 @@ describe('Controladores módulo crear nota de pedido', function() { expect(typeof controlador).toEqual('object'); }); - it('la funcion $scope.crearNotaPedido muestra alerta cuando vendedor es null', function() { - - //arrange - var scope = { - $watch: function() { }, - $broadcast: function() {} - }; - var focaModalService = { - alert: function() { } - }; - - $controler('notaPedidoCtrl', { - $scope: scope, - $uibModal: {}, - $location: {}, - $filter: filter, - $timeout: timeout, - crearNotaPedidoService: { - getNumeroNotaPedido: function() { - return { - then: function() { } - }; - }, - getBotonera: function() { }, - getCotizacionByIdMoneda: function() { - return { - then: function() {} - }; - } - }, - focaBotoneraLateralService: {}, - focaModalService: focaModalService, - notaPedidoBusinessService: {}, - $rootScope: { - $on: function() { } - }, - focaSeguimientoService: {}, - APP: {}, - focaLoginService: {}, - $localStorage: {}, - $watch: function() { }, - $broadcast: function() {} - }); - - //act - scope.notaPedido = { - vendedor: { - id: null - } - }; - spyOn(focaModalService, 'alert'); - scope.crearNotaPedido(); - - //expect - expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Vendedor'); - }); - it('la funcion $scope.crearNotaPedido muestra alerta cuando cliente es null', function() { //arrange diff --git a/src/js/controller.js b/src/js/controller.js index f27c4dc..8ec8fa8 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -443,10 +443,6 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', $scope.seleccionarCliente = function(ocultarVendedor) { $scope.seleccionarVendedor(function() { - if (!$scope.notaPedido.vendedor.NUM) { - focaModalService.alert('Primero seleccione un vendedor'); - return; - } if (validarNotaRemitada()) { var modalInstance = $uibModal.open( { @@ -631,10 +627,6 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', } }; - $scope.seleccionarFlete = function() { - - }; - $scope.seleccionarMoneda = function() { if(validarNotaRemitada()) { var parametrosModal = {