Commit bdf505829de098c2a9b655ba92de607cf0b1d3ab
1 parent
8399773efb
Exists in
master
and in
1 other branch
ok tests
Showing
3 changed files
with
74 additions
and
25 deletions
Show diff stats
package.json
spec/controllerSpec.js
| ... | ... | @@ -29,6 +29,7 @@ describe('Controladores abm vehículo', function() { |
| 29 | 29 | showGuardar: function() { return; }, |
| 30 | 30 | addCustomButton: function() { return; } |
| 31 | 31 | }, |
| 32 | + $localStorage: {}, | |
| 32 | 33 | $timeout: {} |
| 33 | 34 | }); |
| 34 | 35 | |
| ... | ... | @@ -38,7 +39,9 @@ describe('Controladores abm vehículo', function() { |
| 38 | 39 | |
| 39 | 40 | it('Crea fecha nueva', function() { |
| 40 | 41 | //arrange |
| 41 | - var scope = {}; | |
| 42 | + var scope = { | |
| 43 | + $watch: function() {} | |
| 44 | + }; | |
| 42 | 45 | var controller = $controller('focaAbmVehiculosController', { |
| 43 | 46 | $scope: scope, |
| 44 | 47 | focaAbmVehiculoService: { |
| ... | ... | @@ -55,6 +58,7 @@ describe('Controladores abm vehículo', function() { |
| 55 | 58 | showGuardar: function() { return; }, |
| 56 | 59 | addCustomButton: function() { return; } |
| 57 | 60 | }, |
| 61 | + $localStorage: {}, | |
| 58 | 62 | $timeout: {} |
| 59 | 63 | }); |
| 60 | 64 | |
| ... | ... | @@ -67,7 +71,9 @@ describe('Controladores abm vehículo', function() { |
| 67 | 71 | |
| 68 | 72 | it('$scope setea botonera lateral', function() { |
| 69 | 73 | //arrange |
| 70 | - var scope = {}; | |
| 74 | + var scope = { | |
| 75 | + $watch: function() {} | |
| 76 | + }; | |
| 71 | 77 | var controller = $controller('focaAbmVehiculosController', { |
| 72 | 78 | $scope: scope, |
| 73 | 79 | focaAbmVehiculoService: { |
| ... | ... | @@ -84,7 +90,8 @@ describe('Controladores abm vehículo', function() { |
| 84 | 90 | showGuardar: function() { return; }, |
| 85 | 91 | addCustomButton: function() { return; } |
| 86 | 92 | }, |
| 87 | - $timeout: {} | |
| 93 | + $timeout: {}, | |
| 94 | + $localStorage: {} | |
| 88 | 95 | }); |
| 89 | 96 | |
| 90 | 97 | //act |
| ... | ... | @@ -97,7 +104,9 @@ describe('Controladores abm vehículo', function() { |
| 97 | 104 | it('$scope.editar lleva a la ruta correcta', function() { |
| 98 | 105 | inject(function($location) { |
| 99 | 106 | //arrange |
| 100 | - var scope = {}; | |
| 107 | + var scope = { | |
| 108 | + $watch: function() {} | |
| 109 | + }; | |
| 101 | 110 | var controller = $controller('focaAbmVehiculosController', { |
| 102 | 111 | $scope: scope, |
| 103 | 112 | focaAbmVehiculoService: { |
| ... | ... | @@ -114,7 +123,8 @@ describe('Controladores abm vehículo', function() { |
| 114 | 123 | showGuardar: function() { return; }, |
| 115 | 124 | addCustomButton: function() { return; } |
| 116 | 125 | }, |
| 117 | - $timeout: {} | |
| 126 | + $timeout: {}, | |
| 127 | + $localStorage: {} | |
| 118 | 128 | }); |
| 119 | 129 | |
| 120 | 130 | //act |
| ... | ... | @@ -128,7 +138,9 @@ describe('Controladores abm vehículo', function() { |
| 128 | 138 | |
| 129 | 139 | it('Solicita confirmacion', function() { |
| 130 | 140 | //arrange |
| 131 | - var scope = {}; | |
| 141 | + var scope = { | |
| 142 | + $watch: function() {} | |
| 143 | + }; | |
| 132 | 144 | var focaModalService = { |
| 133 | 145 | confirm: function() {} |
| 134 | 146 | }; |
| ... | ... | @@ -148,7 +160,8 @@ describe('Controladores abm vehículo', function() { |
| 148 | 160 | showGuardar: function() { return; }, |
| 149 | 161 | addCustomButton: function() { return; } |
| 150 | 162 | }, |
| 151 | - $timeout: {} | |
| 163 | + $timeout: {}, | |
| 164 | + $localStorage: {} | |
| 152 | 165 | }); |
| 153 | 166 | |
| 154 | 167 | //act |
| ... | ... | @@ -186,7 +199,8 @@ describe('Controladores abm vehículo', function() { |
| 186 | 199 | showGuardar: function() { return; }, |
| 187 | 200 | addCustomButton: function() { return; } |
| 188 | 201 | }, |
| 189 | - $timeout: {} | |
| 202 | + $timeout: {}, | |
| 203 | + $localStorage: {} | |
| 190 | 204 | }); |
| 191 | 205 | var promesa = Promise.resolve(true); |
| 192 | 206 | |
| ... | ... | @@ -206,7 +220,9 @@ describe('Controladores abm vehículo', function() { |
| 206 | 220 | |
| 207 | 221 | it('Se selecciona transportista', function() { |
| 208 | 222 | //arrange |
| 209 | - var scope = {}; | |
| 223 | + var scope = { | |
| 224 | + $watch: function() {} | |
| 225 | + }; | |
| 210 | 226 | var focaModalService = { |
| 211 | 227 | modal: function() {} |
| 212 | 228 | }; |
| ... | ... | @@ -226,7 +242,8 @@ describe('Controladores abm vehículo', function() { |
| 226 | 242 | showGuardar: function() { return; }, |
| 227 | 243 | addCustomButton: function() { return; } |
| 228 | 244 | }, |
| 229 | - $timeout: {} | |
| 245 | + $timeout: {}, | |
| 246 | + $localStorage: {} | |
| 230 | 247 | }); |
| 231 | 248 | |
| 232 | 249 | //act |
| ... | ... | @@ -241,7 +258,9 @@ describe('Controladores abm vehículo', function() { |
| 241 | 258 | inject(function($timeout) { |
| 242 | 259 | |
| 243 | 260 | //arrange |
| 244 | - var scope = {}; | |
| 261 | + var scope = { | |
| 262 | + $watch: function() {} | |
| 263 | + }; | |
| 245 | 264 | var focaModalService = { |
| 246 | 265 | modal: function() { return; } |
| 247 | 266 | }; |
| ... | ... | @@ -268,6 +287,7 @@ describe('Controladores abm vehículo', function() { |
| 268 | 287 | showGuardar: function() { return; }, |
| 269 | 288 | addCustomButton: function() { return; } |
| 270 | 289 | }, |
| 290 | + $localStorage: {}, | |
| 271 | 291 | $timeout: $timeout |
| 272 | 292 | }); |
| 273 | 293 | var promesa = Promise.resolve({COD: '', NOM: ''}); |
| ... | ... | @@ -301,7 +321,9 @@ describe('Controladores abm vehículo', function() { |
| 301 | 321 | |
| 302 | 322 | //arrange |
| 303 | 323 | var controller = $controller('focaAbmVehiculoController', { |
| 304 | - $scope: {}, | |
| 324 | + $scope: { | |
| 325 | + $watch: function() {} | |
| 326 | + }, | |
| 305 | 327 | focaAbmVehiculoService: { |
| 306 | 328 | getVehiculo: function() { |
| 307 | 329 | return { |
| ... | ... | @@ -321,6 +343,7 @@ describe('Controladores abm vehículo', function() { |
| 321 | 343 | showGuardar: function() { return; }, |
| 322 | 344 | addCustomButton: function() { return; } |
| 323 | 345 | }, |
| 346 | + $localStorage: {}, | |
| 324 | 347 | $window: {} |
| 325 | 348 | }); |
| 326 | 349 | |
| ... | ... | @@ -332,7 +355,9 @@ describe('Controladores abm vehículo', function() { |
| 332 | 355 | it('Se busca el transportista cuando es nuevo', function() { |
| 333 | 356 | |
| 334 | 357 | //arrange |
| 335 | - var scope = {}; | |
| 358 | + var scope = { | |
| 359 | + $watch: function() {} | |
| 360 | + }; | |
| 336 | 361 | var focaAbmVehiculoService = { |
| 337 | 362 | getVehiculo: function() { |
| 338 | 363 | return { |
| ... | ... | @@ -363,6 +388,7 @@ describe('Controladores abm vehículo', function() { |
| 363 | 388 | showGuardar: function() { return; }, |
| 364 | 389 | addCustomButton: function() { return; } |
| 365 | 390 | }, |
| 391 | + $localStorage: {}, | |
| 366 | 392 | $window: {} |
| 367 | 393 | }); |
| 368 | 394 | |
| ... | ... | @@ -373,7 +399,9 @@ describe('Controladores abm vehículo', function() { |
| 373 | 399 | it('No se busca el transportista cuando es nuevo', function() { |
| 374 | 400 | |
| 375 | 401 | //arrange |
| 376 | - var scope = {}; | |
| 402 | + var scope = { | |
| 403 | + $watch: function() {} | |
| 404 | + }; | |
| 377 | 405 | var focaAbmVehiculoService = { |
| 378 | 406 | getVehiculo: function() { |
| 379 | 407 | return { |
| ... | ... | @@ -402,6 +430,7 @@ describe('Controladores abm vehículo', function() { |
| 402 | 430 | showGuardar: function() { return; }, |
| 403 | 431 | addCustomButton: function() { return; } |
| 404 | 432 | }, |
| 433 | + $localStorage: {}, | |
| 405 | 434 | $window: {} |
| 406 | 435 | }); |
| 407 | 436 | |
| ... | ... | @@ -413,7 +442,13 @@ describe('Controladores abm vehículo', function() { |
| 413 | 442 | |
| 414 | 443 | inject(function($location) { |
| 415 | 444 | //arrange |
| 416 | - var scope = {}; | |
| 445 | + var scope = { | |
| 446 | + $watch: function() {}, | |
| 447 | + cancelar: function() {}, | |
| 448 | + formVehiculo: { | |
| 449 | + $pristine: true | |
| 450 | + } | |
| 451 | + }; | |
| 417 | 452 | var controller = $controller('focaAbmVehiculoController', { |
| 418 | 453 | $scope: scope, |
| 419 | 454 | focaAbmVehiculoService: { |
| ... | ... | @@ -435,11 +470,13 @@ describe('Controladores abm vehículo', function() { |
| 435 | 470 | showGuardar: function() { return; }, |
| 436 | 471 | addCustomButton: function() { return; } |
| 437 | 472 | }, |
| 438 | - $window: {} | |
| 473 | + $localStorage: {}, | |
| 474 | + $window: {}, | |
| 475 | + | |
| 439 | 476 | }); |
| 440 | 477 | |
| 441 | 478 | //act |
| 442 | - scope.cancelar(); | |
| 479 | + scope.salir(); | |
| 443 | 480 | |
| 444 | 481 | //assert |
| 445 | 482 | expect($location.url()).toEqual('/vehiculo'); |
| ... | ... | @@ -450,7 +487,9 @@ describe('Controladores abm vehículo', function() { |
| 450 | 487 | |
| 451 | 488 | inject(function($location) { |
| 452 | 489 | //arrange |
| 453 | - var scope = {}; | |
| 490 | + var scope = { | |
| 491 | + $watch: function() {} | |
| 492 | + }; | |
| 454 | 493 | var controller = $controller('focaAbmVehiculoController', { |
| 455 | 494 | $scope: scope, |
| 456 | 495 | focaAbmVehiculoService: { |
| ... | ... | @@ -474,6 +513,7 @@ describe('Controladores abm vehículo', function() { |
| 474 | 513 | showGuardar: function() { return; }, |
| 475 | 514 | addCustomButton: function() { return; } |
| 476 | 515 | }, |
| 516 | + $localStorage: {}, | |
| 477 | 517 | $window: {} |
| 478 | 518 | }); |
| 479 | 519 | |
| ... | ... | @@ -490,7 +530,9 @@ describe('Controladores abm vehículo', function() { |
| 490 | 530 | |
| 491 | 531 | inject(function($location) { |
| 492 | 532 | //arrange |
| 493 | - var scope = {}; | |
| 533 | + var scope = { | |
| 534 | + $watch: function() {} | |
| 535 | + }; | |
| 494 | 536 | var controller = $controller('focaAbmVehiculoController', { |
| 495 | 537 | $scope: scope, |
| 496 | 538 | focaAbmVehiculoService: { |
| ... | ... | @@ -514,6 +556,7 @@ describe('Controladores abm vehículo', function() { |
| 514 | 556 | showGuardar: function() { return; }, |
| 515 | 557 | addCustomButton: function() { return; } |
| 516 | 558 | }, |
| 559 | + $localStorage: {}, | |
| 517 | 560 | $window: {} |
| 518 | 561 | }); |
| 519 | 562 | |
| ... | ... | @@ -532,7 +575,9 @@ describe('Controladores abm vehículo', function() { |
| 532 | 575 | var focaModalService = { |
| 533 | 576 | confirm: function() {} |
| 534 | 577 | }; |
| 535 | - var scope = {}; | |
| 578 | + var scope = { | |
| 579 | + $watch: function() {} | |
| 580 | + }; | |
| 536 | 581 | var controller = $controller('focaAbmVehiculoController', { |
| 537 | 582 | $scope: scope, |
| 538 | 583 | focaAbmVehiculoService: { |
| ... | ... | @@ -556,6 +601,7 @@ describe('Controladores abm vehículo', function() { |
| 556 | 601 | showGuardar: function() { return; }, |
| 557 | 602 | addCustomButton: function() { return; } |
| 558 | 603 | }, |
| 604 | + $localStorage: {}, | |
| 559 | 605 | $window: {} |
| 560 | 606 | }); |
| 561 | 607 | |
| ... | ... | @@ -570,7 +616,9 @@ describe('Controladores abm vehículo', function() { |
| 570 | 616 | it('Elimina y obtiene cisternas al dar confirmar', function(done) { |
| 571 | 617 | |
| 572 | 618 | //arrange |
| 573 | - var scope = {}; | |
| 619 | + var scope = { | |
| 620 | + $watch: function() {} | |
| 621 | + }; | |
| 574 | 622 | var focaModalService = { |
| 575 | 623 | confirm: function() {} |
| 576 | 624 | }; |
| ... | ... | @@ -598,6 +646,7 @@ describe('Controladores abm vehículo', function() { |
| 598 | 646 | showGuardar: function() { return; }, |
| 599 | 647 | addCustomButton: function() { return; } |
| 600 | 648 | }, |
| 649 | + $localStorage: {}, | |
| 601 | 650 | $window: {} |
| 602 | 651 | }); |
| 603 | 652 | var promesa = Promise.resolve(true); |
src/js/controller.js
| ... | ... | @@ -107,7 +107,7 @@ angular.module('focaAbmVehiculo') |
| 107 | 107 | focaBotoneraLateralService.showPausar(true); |
| 108 | 108 | focaBotoneraLateralService.showCancelar(false); |
| 109 | 109 | focaBotoneraLateralService.showGuardar(true, $scope.guardar); |
| 110 | - focaBotoneraLateralService.addCustomButton('Salir', salir); | |
| 110 | + focaBotoneraLateralService.addCustomButton('Salir', $scope.salir); | |
| 111 | 111 | }); |
| 112 | 112 | |
| 113 | 113 | $timeout(function() {getLSVehiculo();}); |
| ... | ... | @@ -153,7 +153,7 @@ angular.module('focaAbmVehiculo') |
| 153 | 153 | if (key === 13) $scope.focused++; |
| 154 | 154 | }; |
| 155 | 155 | |
| 156 | - function salir() { | |
| 156 | + $scope.salir = function() { | |
| 157 | 157 | if (!$scope.formVehiculo.$pristine && focaAbmVehiculoService.cisternasPristine) { |
| 158 | 158 | focaModalService.confirm( |
| 159 | 159 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' |
| ... | ... | @@ -182,7 +182,7 @@ angular.module('focaAbmVehiculo') |
| 182 | 182 | if (key === 13) { |
| 183 | 183 | |
| 184 | 184 | if ($scope.formVehiculo.$pristine && focaAbmVehiculoService.cisternasPristine) { |
| 185 | - salir(); | |
| 185 | + $scope.salir(); | |
| 186 | 186 | return; |
| 187 | 187 | } |
| 188 | 188 |