diff --git a/spec/controllerSpec.js b/spec/controllerSpec.js index 5e40f25..4a55623 100644 --- a/spec/controllerSpec.js +++ b/spec/controllerSpec.js @@ -154,6 +154,11 @@ describe('Controladores módulo crear hoja de ruta', function() { return { then: function() { } }; + }, + getParametros: function () { + return { + then: function() { } + }; } }, focaModalService: {}, @@ -189,6 +194,11 @@ describe('Controladores módulo crear hoja de ruta', function() { return { then: function() { } }; + }, + getParametros: function () { + return { + then: function() { } + }; } }, focaModalService: focaModalService, @@ -230,6 +240,11 @@ describe('Controladores módulo crear hoja de ruta', function() { return { then: function() { } }; + }, + getParametros: function () { + return { + then: function() { } + }; } }, focaModalService: focaModalService, @@ -275,6 +290,11 @@ describe('Controladores módulo crear hoja de ruta', function() { return { then: function() { } }; + }, + getParametros: function () { + return { + then: function() { } + }; } }, focaModalService: focaModalService, @@ -320,6 +340,11 @@ describe('Controladores módulo crear hoja de ruta', function() { return { then: function() { } }; + }, + getParametros: function () { + return { + then: function() { } + }; } }, focaModalService: focaModalService, @@ -366,6 +391,11 @@ describe('Controladores módulo crear hoja de ruta', function() { return { then: function() { } }; + }, + getParametros: function () { + return { + then: function() { } + }; } }, focaModalService: focaModalService, @@ -377,7 +407,6 @@ describe('Controladores módulo crear hoja de ruta', function() { chofer: { id: true }, vehiculo: { id: true }, transportista: { COD: true }, - tarifario: { }, remitosTabla: [1] }; @@ -413,6 +442,11 @@ describe('Controladores módulo crear hoja de ruta', function() { return { then: function() { } }; + }, + getParametros: function () { + return { + then: function() { } + }; } }, focaModalService: focaModalService, @@ -451,7 +485,12 @@ describe('Controladores módulo crear hoja de ruta', function() { then: function() { } }; }, - crearHojaRuta: function() { } + crearHojaRuta: function() { }, + getParametros: function () { + return { + then: function() { } + }; + } }; $controller('hojaRutaCtrl', { @@ -510,6 +549,11 @@ describe('Controladores módulo crear hoja de ruta', function() { return { then: function() { } }; + }, + getParametros: function () { + return { + then: function() { } + }; } }, focaModalService: focaModalService, @@ -560,6 +604,11 @@ describe('Controladores módulo crear hoja de ruta', function() { return { then: function() { } }; + }, + getParametros: function () { + return { + then: function() { } + }; } }, focaModalService: focaModalService, @@ -610,6 +659,11 @@ describe('Controladores módulo crear hoja de ruta', function() { return { then: function() { } }; + }, + getParametros: function () { + return { + then: function() { } + }; } }, focaModalService: focaModalService, @@ -631,7 +685,7 @@ describe('Controladores módulo crear hoja de ruta', function() { promesa.then(function() { expect(focaModalService.prompt).toHaveBeenCalled(); expect(scope.$broadcast).toHaveBeenCalled(); - expect(scope.hojaRuta.tarifario.costo).toEqual(respuesta); + expect(scope.hojaRuta.tarifario).toEqual(respuesta); done(); }); @@ -660,6 +714,11 @@ describe('Controladores módulo crear hoja de ruta', function() { return { then: function() { } }; + }, + getParametros: function () { + return { + then: function() { } + }; } }, focaModalService: { @@ -715,6 +774,11 @@ describe('Controladores módulo crear hoja de ruta', function() { return { then: function() { } }; + }, + getParametros: function () { + return { + then: function() { } + }; } }; @@ -780,6 +844,11 @@ describe('Controladores módulo crear hoja de ruta', function() { return { then: function() { } }; + }, + getParametros: function () { + return { + then: function() { } + }; } }, focaModalService: { @@ -822,7 +891,10 @@ describe('Controladores módulo crear hoja de ruta', function() { $watch: function() {} }; var focaModalService = { - modalFecha: function() { } + modalFecha: function() { }, + confirm: function() { + return Promise.resolve({}); + } }; $controller('hojaRutaCtrl', { @@ -837,6 +909,11 @@ describe('Controladores módulo crear hoja de ruta', function() { return { then: function() { } }; + }, + getParametros: function () { + return { + then: function() { } + }; } }, focaModalService: focaModalService, @@ -856,9 +933,12 @@ describe('Controladores módulo crear hoja de ruta', function() { //assert promesa.then(function() { - expect(focaModalService.modalFecha).toHaveBeenCalled(); - expect(scope.$broadcast).toHaveBeenCalled(); - done(); + setTimeout(function() { + + expect(focaModalService.modalFecha).toHaveBeenCalled(); + expect(scope.$broadcast).toHaveBeenCalled(); + done(); + }); }); }); diff --git a/src/js/controller.js b/src/js/controller.js index 31e506a..9f7500a 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -43,6 +43,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', for(var property in parametros) { $scope.hojaRuta[property] = parametros[property]; + $scope.inicial[property] = parametros[property]; } setearHojaRuta($scope.hojaRuta); @@ -370,7 +371,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', $scope.seleccionarFechaEntrega = function() { var confirmacion = false; var hasVehiculoId = $scope.hojaRuta.vehiculo.id !== undefined; - var hasTarifario = $scope.hojaRuta.tarifario.costo !== null; + var hasTarifario = $scope.hojaRuta.tarifario !== null; var hasTransportista = Object.keys($scope.hojaRuta.transportista).length > 0; var hasChofer = Object.keys($scope.hojaRuta.chofer).length > 0; var hasDatosExtra = $scope.hojaRuta.datosExtra !== undefined; @@ -384,7 +385,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', .then(function(data) { if(data) { $scope.hojaRuta.vehiculo.id = undefined; - $scope.hojaRuta.tarifario.costo = null; + $scope.hojaRuta.tarifario = null; $scope.hojaRuta.transportista = {}; $scope.hojaRuta.chofer = {}; $scope.hojaRuta.datosExtra = undefined; @@ -397,7 +398,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', } else { elegirFecha(); } - } + }; function setearFecha(fecha) { $timeout(function() { @@ -406,6 +407,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', valor: fecha.toLocaleDateString() }); $scope.hojaRuta.fechaReparto = fecha; + $scope.inicial.fechaReparto = fecha; }); } @@ -480,6 +482,8 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', }; focaModalService.modalFecha(fechaEntrega).then(function(fecha) { + $scope.hojaRuta.fechaReparto = fecha; + $scope.$broadcast('addCabecera', { label: 'Fecha de entrega: ', valor: fecha.toLocaleDateString() @@ -488,8 +492,6 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', $filter('filter')($scope.botonera, { label: 'Fecha Entrega', })[0].checked = true; - - $scope.hojaRuta.fechaReparto = fecha; }); }