Commit 964fefb9683c96a49f911173a910d44cca21bdc3
1 parent
d7d1f41214
Exists in
master
scope.incial init test
Showing
2 changed files
with
94 additions
and
12 deletions
 
Show diff stats
spec/controllerSpec.js
| ... | ... | @@ -154,6 +154,11 @@ describe('Controladores módulo crear hoja de ruta', function() { | 
| 154 | 154 | return { | 
| 155 | 155 | then: function() { } | 
| 156 | 156 | }; | 
| 157 | + }, | |
| 158 | + getParametros: function () { | |
| 159 | + return { | |
| 160 | + then: function() { } | |
| 161 | + }; | |
| 157 | 162 | } | 
| 158 | 163 | }, | 
| 159 | 164 | focaModalService: {}, | 
| ... | ... | @@ -189,6 +194,11 @@ describe('Controladores módulo crear hoja de ruta', function() { | 
| 189 | 194 | return { | 
| 190 | 195 | then: function() { } | 
| 191 | 196 | }; | 
| 197 | + }, | |
| 198 | + getParametros: function () { | |
| 199 | + return { | |
| 200 | + then: function() { } | |
| 201 | + }; | |
| 192 | 202 | } | 
| 193 | 203 | }, | 
| 194 | 204 | focaModalService: focaModalService, | 
| ... | ... | @@ -230,6 +240,11 @@ describe('Controladores módulo crear hoja de ruta', function() { | 
| 230 | 240 | return { | 
| 231 | 241 | then: function() { } | 
| 232 | 242 | }; | 
| 243 | + }, | |
| 244 | + getParametros: function () { | |
| 245 | + return { | |
| 246 | + then: function() { } | |
| 247 | + }; | |
| 233 | 248 | } | 
| 234 | 249 | }, | 
| 235 | 250 | focaModalService: focaModalService, | 
| ... | ... | @@ -275,6 +290,11 @@ describe('Controladores módulo crear hoja de ruta', function() { | 
| 275 | 290 | return { | 
| 276 | 291 | then: function() { } | 
| 277 | 292 | }; | 
| 293 | + }, | |
| 294 | + getParametros: function () { | |
| 295 | + return { | |
| 296 | + then: function() { } | |
| 297 | + }; | |
| 278 | 298 | } | 
| 279 | 299 | }, | 
| 280 | 300 | focaModalService: focaModalService, | 
| ... | ... | @@ -320,6 +340,11 @@ describe('Controladores módulo crear hoja de ruta', function() { | 
| 320 | 340 | return { | 
| 321 | 341 | then: function() { } | 
| 322 | 342 | }; | 
| 343 | + }, | |
| 344 | + getParametros: function () { | |
| 345 | + return { | |
| 346 | + then: function() { } | |
| 347 | + }; | |
| 323 | 348 | } | 
| 324 | 349 | }, | 
| 325 | 350 | focaModalService: focaModalService, | 
| ... | ... | @@ -366,6 +391,11 @@ describe('Controladores módulo crear hoja de ruta', function() { | 
| 366 | 391 | return { | 
| 367 | 392 | then: function() { } | 
| 368 | 393 | }; | 
| 394 | + }, | |
| 395 | + getParametros: function () { | |
| 396 | + return { | |
| 397 | + then: function() { } | |
| 398 | + }; | |
| 369 | 399 | } | 
| 370 | 400 | }, | 
| 371 | 401 | focaModalService: focaModalService, | 
| ... | ... | @@ -377,7 +407,6 @@ describe('Controladores módulo crear hoja de ruta', function() { | 
| 377 | 407 | chofer: { id: true }, | 
| 378 | 408 | vehiculo: { id: true }, | 
| 379 | 409 | transportista: { COD: true }, | 
| 380 | - tarifario: { }, | |
| 381 | 410 | remitosTabla: [1] | 
| 382 | 411 | }; | 
| 383 | 412 | |
| ... | ... | @@ -413,6 +442,11 @@ describe('Controladores módulo crear hoja de ruta', function() { | 
| 413 | 442 | return { | 
| 414 | 443 | then: function() { } | 
| 415 | 444 | }; | 
| 445 | + }, | |
| 446 | + getParametros: function () { | |
| 447 | + return { | |
| 448 | + then: function() { } | |
| 449 | + }; | |
| 416 | 450 | } | 
| 417 | 451 | }, | 
| 418 | 452 | focaModalService: focaModalService, | 
| ... | ... | @@ -451,7 +485,12 @@ describe('Controladores módulo crear hoja de ruta', function() { | 
| 451 | 485 | then: function() { } | 
| 452 | 486 | }; | 
| 453 | 487 | }, | 
| 454 | - crearHojaRuta: function() { } | |
| 488 | + crearHojaRuta: function() { }, | |
| 489 | + getParametros: function () { | |
| 490 | + return { | |
| 491 | + then: function() { } | |
| 492 | + }; | |
| 493 | + } | |
| 455 | 494 | }; | 
| 456 | 495 | |
| 457 | 496 | $controller('hojaRutaCtrl', { | 
| ... | ... | @@ -510,6 +549,11 @@ describe('Controladores módulo crear hoja de ruta', function() { | 
| 510 | 549 | return { | 
| 511 | 550 | then: function() { } | 
| 512 | 551 | }; | 
| 552 | + }, | |
| 553 | + getParametros: function () { | |
| 554 | + return { | |
| 555 | + then: function() { } | |
| 556 | + }; | |
| 513 | 557 | } | 
| 514 | 558 | }, | 
| 515 | 559 | focaModalService: focaModalService, | 
| ... | ... | @@ -560,6 +604,11 @@ describe('Controladores módulo crear hoja de ruta', function() { | 
| 560 | 604 | return { | 
| 561 | 605 | then: function() { } | 
| 562 | 606 | }; | 
| 607 | + }, | |
| 608 | + getParametros: function () { | |
| 609 | + return { | |
| 610 | + then: function() { } | |
| 611 | + }; | |
| 563 | 612 | } | 
| 564 | 613 | }, | 
| 565 | 614 | focaModalService: focaModalService, | 
| ... | ... | @@ -610,6 +659,11 @@ describe('Controladores módulo crear hoja de ruta', function() { | 
| 610 | 659 | return { | 
| 611 | 660 | then: function() { } | 
| 612 | 661 | }; | 
| 662 | + }, | |
| 663 | + getParametros: function () { | |
| 664 | + return { | |
| 665 | + then: function() { } | |
| 666 | + }; | |
| 613 | 667 | } | 
| 614 | 668 | }, | 
| 615 | 669 | focaModalService: focaModalService, | 
| ... | ... | @@ -631,7 +685,7 @@ describe('Controladores módulo crear hoja de ruta', function() { | 
| 631 | 685 | promesa.then(function() { | 
| 632 | 686 | expect(focaModalService.prompt).toHaveBeenCalled(); | 
| 633 | 687 | expect(scope.$broadcast).toHaveBeenCalled(); | 
| 634 | - expect(scope.hojaRuta.tarifario.costo).toEqual(respuesta); | |
| 688 | + expect(scope.hojaRuta.tarifario).toEqual(respuesta); | |
| 635 | 689 | done(); | 
| 636 | 690 | }); | 
| 637 | 691 | |
| ... | ... | @@ -660,6 +714,11 @@ describe('Controladores módulo crear hoja de ruta', function() { | 
| 660 | 714 | return { | 
| 661 | 715 | then: function() { } | 
| 662 | 716 | }; | 
| 717 | + }, | |
| 718 | + getParametros: function () { | |
| 719 | + return { | |
| 720 | + then: function() { } | |
| 721 | + }; | |
| 663 | 722 | } | 
| 664 | 723 | }, | 
| 665 | 724 | focaModalService: { | 
| ... | ... | @@ -715,6 +774,11 @@ describe('Controladores módulo crear hoja de ruta', function() { | 
| 715 | 774 | return { | 
| 716 | 775 | then: function() { } | 
| 717 | 776 | }; | 
| 777 | + }, | |
| 778 | + getParametros: function () { | |
| 779 | + return { | |
| 780 | + then: function() { } | |
| 781 | + }; | |
| 718 | 782 | } | 
| 719 | 783 | }; | 
| 720 | 784 | |
| ... | ... | @@ -780,6 +844,11 @@ describe('Controladores módulo crear hoja de ruta', function() { | 
| 780 | 844 | return { | 
| 781 | 845 | then: function() { } | 
| 782 | 846 | }; | 
| 847 | + }, | |
| 848 | + getParametros: function () { | |
| 849 | + return { | |
| 850 | + then: function() { } | |
| 851 | + }; | |
| 783 | 852 | } | 
| 784 | 853 | }, | 
| 785 | 854 | focaModalService: { | 
| ... | ... | @@ -822,7 +891,10 @@ describe('Controladores módulo crear hoja de ruta', function() { | 
| 822 | 891 | $watch: function() {} | 
| 823 | 892 | }; | 
| 824 | 893 | var focaModalService = { | 
| 825 | - modalFecha: function() { } | |
| 894 | + modalFecha: function() { }, | |
| 895 | + confirm: function() { | |
| 896 | + return Promise.resolve({}); | |
| 897 | + } | |
| 826 | 898 | }; | 
| 827 | 899 | |
| 828 | 900 | $controller('hojaRutaCtrl', { | 
| ... | ... | @@ -837,6 +909,11 @@ describe('Controladores módulo crear hoja de ruta', function() { | 
| 837 | 909 | return { | 
| 838 | 910 | then: function() { } | 
| 839 | 911 | }; | 
| 912 | + }, | |
| 913 | + getParametros: function () { | |
| 914 | + return { | |
| 915 | + then: function() { } | |
| 916 | + }; | |
| 840 | 917 | } | 
| 841 | 918 | }, | 
| 842 | 919 | focaModalService: focaModalService, | 
| ... | ... | @@ -856,9 +933,12 @@ describe('Controladores módulo crear hoja de ruta', function() { | 
| 856 | 933 | |
| 857 | 934 | //assert | 
| 858 | 935 | promesa.then(function() { | 
| 859 | - expect(focaModalService.modalFecha).toHaveBeenCalled(); | |
| 860 | - expect(scope.$broadcast).toHaveBeenCalled(); | |
| 861 | - done(); | |
| 936 | + setTimeout(function() { | |
| 937 | + | |
| 938 | + expect(focaModalService.modalFecha).toHaveBeenCalled(); | |
| 939 | + expect(scope.$broadcast).toHaveBeenCalled(); | |
| 940 | + done(); | |
| 941 | + }); | |
| 862 | 942 | }); | 
| 863 | 943 | |
| 864 | 944 | }); | 
src/js/controller.js
| ... | ... | @@ -43,6 +43,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', | 
| 43 | 43 | |
| 44 | 44 | for(var property in parametros) { | 
| 45 | 45 | $scope.hojaRuta[property] = parametros[property]; | 
| 46 | + $scope.inicial[property] = parametros[property]; | |
| 46 | 47 | } | 
| 47 | 48 | |
| 48 | 49 | setearHojaRuta($scope.hojaRuta); | 
| ... | ... | @@ -370,7 +371,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', | 
| 370 | 371 | $scope.seleccionarFechaEntrega = function() { | 
| 371 | 372 | var confirmacion = false; | 
| 372 | 373 | var hasVehiculoId = $scope.hojaRuta.vehiculo.id !== undefined; | 
| 373 | - var hasTarifario = $scope.hojaRuta.tarifario.costo !== null; | |
| 374 | + var hasTarifario = $scope.hojaRuta.tarifario !== null; | |
| 374 | 375 | var hasTransportista = Object.keys($scope.hojaRuta.transportista).length > 0; | 
| 375 | 376 | var hasChofer = Object.keys($scope.hojaRuta.chofer).length > 0; | 
| 376 | 377 | var hasDatosExtra = $scope.hojaRuta.datosExtra !== undefined; | 
| ... | ... | @@ -384,7 +385,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', | 
| 384 | 385 | .then(function(data) { | 
| 385 | 386 | if(data) { | 
| 386 | 387 | $scope.hojaRuta.vehiculo.id = undefined; | 
| 387 | - $scope.hojaRuta.tarifario.costo = null; | |
| 388 | + $scope.hojaRuta.tarifario = null; | |
| 388 | 389 | $scope.hojaRuta.transportista = {}; | 
| 389 | 390 | $scope.hojaRuta.chofer = {}; | 
| 390 | 391 | $scope.hojaRuta.datosExtra = undefined; | 
| ... | ... | @@ -397,7 +398,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', | 
| 397 | 398 | } else { | 
| 398 | 399 | elegirFecha(); | 
| 399 | 400 | } | 
| 400 | - } | |
| 401 | + }; | |
| 401 | 402 | |
| 402 | 403 | function setearFecha(fecha) { | 
| 403 | 404 | $timeout(function() { | 
| ... | ... | @@ -406,6 +407,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', | 
| 406 | 407 | valor: fecha.toLocaleDateString() | 
| 407 | 408 | }); | 
| 408 | 409 | $scope.hojaRuta.fechaReparto = fecha; | 
| 410 | + $scope.inicial.fechaReparto = fecha; | |
| 409 | 411 | }); | 
| 410 | 412 | } | 
| 411 | 413 | |
| ... | ... | @@ -480,6 +482,8 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', | 
| 480 | 482 | }; | 
| 481 | 483 | focaModalService.modalFecha(fechaEntrega).then(function(fecha) { | 
| 482 | 484 | |
| 485 | + $scope.hojaRuta.fechaReparto = fecha; | |
| 486 | + | |
| 483 | 487 | $scope.$broadcast('addCabecera', { | 
| 484 | 488 | label: 'Fecha de entrega: ', | 
| 485 | 489 | valor: fecha.toLocaleDateString() | 
| ... | ... | @@ -488,8 +492,6 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', | 
| 488 | 492 | $filter('filter')($scope.botonera, { | 
| 489 | 493 | label: 'Fecha Entrega', | 
| 490 | 494 | })[0].checked = true; | 
| 491 | - | |
| 492 | - $scope.hojaRuta.fechaReparto = fecha; | |
| 493 | 495 | }); | 
| 494 | 496 | } | 
| 495 | 497 |