Commit 99532cb1a9119ceb07a18b0e990bf6a50e85b646

Authored by Nicolás Guarnieri
Exists in master and in 1 other branch develop

Merge branch 'master' into 'master'

Master(efernandez)

See merge request !48
... ... @@ -9,10 +9,13 @@ const pump = require('pump');
9 9 const jshint = require('gulp-jshint');
10 10 const replace = require('gulp-replace');
11 11 const connect = require('gulp-connect');
  12 +const header = require('gulp-header');
  13 +const footer = require('gulp-footer');
12 14  
13 15 var paths = {
14 16 srcJS: 'src/js/*.js',
15 17 srcViews: 'src/views/*.html',
  18 + specs: 'spec/*.js',
16 19 tmp: 'tmp',
17 20 dist: 'dist/'
18 21 };
... ... @@ -31,7 +34,7 @@ gulp.task('templates', ['clean'], function() {
31 34 );
32 35 });
33 36  
34   -gulp.task('uglify', ['templates'], function() {
  37 +gulp.task('uglify', ['templates', 'uglify-spec'], function() {
35 38 return pump(
36 39 [
37 40 gulp.src([
... ... @@ -48,6 +51,17 @@ gulp.task('uglify', ['templates'], function() {
48 51 );
49 52 });
50 53  
  54 +gulp.task('uglify-spec', function() {
  55 + return pump([
  56 + gulp.src(paths.specs),
  57 + concat('foca-crear-nota-pedido.spec.js'),
  58 + replace("src/views/", ''),
  59 + header("describe('Módulo foca-crear-nota-pedido', function() { \n"),
  60 + footer("});"),
  61 + gulp.dest(paths.dist)
  62 + ]);
  63 +});
  64 +
51 65 gulp.task('clean', function() {
52 66 return gulp.src(['tmp', 'dist'], {read: false})
53 67 .pipe(clean());
... ... @@ -56,7 +70,7 @@ gulp.task('clean', function() {
56 70 gulp.task('pre-commit', function() {
57 71 return pump(
58 72 [
59   - gulp.src(paths.srcJS),
  73 + gulp.src([paths.srcJS, paths.specs]),
60 74 jshint('.jshintrc'),
61 75 jshint.reporter('default'),
62 76 jshint.reporter('fail')
... ... @@ -74,7 +88,7 @@ gulp.task('webserver', function() {
74 88  
75 89 gulp.task('clean-post-install', function() {
76 90 return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js',
77   - 'index.html'], {read: false})
  91 + 'index.html', 'test.html', 'spec'], {read: false})
78 92 .pipe(clean());
79 93 });
80 94  
... ... @@ -4,7 +4,7 @@
4 4 "description": "Listado y ABM nota de pedidos",
5 5 "main": "index.js",
6 6 "scripts": {
7   - "test": "echo \"Error: no test specified\" && exit 1",
  7 + "test": "test.html",
8 8 "compile": "gulp uglify",
9 9 "gulp-pre-commit": "gulp pre-commit",
10 10 "postinstall": "npm run compile && gulp clean-post-install",
... ... @@ -37,6 +37,7 @@
37 37 "devDependencies": {
38 38 "angular": "^1.7.5",
39 39 "angular-ladda": "^0.4.3",
  40 + "angular-mocks": "^1.7.7",
40 41 "angular-route": "^1.7.5",
41 42 "bootstrap": "^4.1.3",
42 43 "foca-busqueda-cliente": "git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git",
spec/controllerSpec.js
... ... @@ -0,0 +1,1491 @@
  1 +describe('Controladores módulo crear nota de pedido', function() {
  2 +
  3 + var $controler;
  4 +
  5 + beforeEach(function() {
  6 + module('focaCrearNotaPedido');
  7 + inject(function(_$controller_) {
  8 + $controler = _$controller_;
  9 + });
  10 + });
  11 +
  12 + describe('Controlador notaPedidoCtrl', function() {
  13 +
  14 + var filter = function() {
  15 + return function() { };
  16 + };
  17 + var timeout;
  18 +
  19 + beforeEach(function() {
  20 +
  21 + inject(function($timeout) {
  22 + timeout = $timeout;
  23 + });
  24 + });
  25 +
  26 + it('La función seleccionarNotaPedido levanta modal', function() {
  27 + //arrange
  28 + var scope = {};
  29 + var uibModal = {
  30 + open: function() { }
  31 + };
  32 +
  33 + $controler('notaPedidoCtrl', {
  34 + $scope: scope,
  35 + $uibModal: uibModal,
  36 + $location: {},
  37 + $filter: filter,
  38 + $timeout: timeout,
  39 + crearNotaPedidoService: {
  40 + getBotonera: function() { },
  41 + getCotizacionByIdMoneda: function() {
  42 + return {
  43 + then: function() { }
  44 + };
  45 + }
  46 + },
  47 + focaBotoneraLateralService: {},
  48 + focaModalService: {},
  49 + notaPedidoBusinessService: {},
  50 + $rootScope: {
  51 + $on: function() { }
  52 + },
  53 + focaSeguimientoService: {},
  54 + APP: {},
  55 + focaLoginService: {}
  56 + });
  57 + var respuesta = { result: { then: function() { } } };
  58 +
  59 + //act
  60 + spyOn(uibModal, 'open').and.returnValue(respuesta);
  61 + scope.seleccionarNotaPedido();
  62 +
  63 + //assert
  64 + expect(uibModal.open).toHaveBeenCalled();
  65 + });
  66 +
  67 + it('La función seleccionarNotaPedido llama a broadCast en promesa', function(done) {
  68 + //arrange
  69 + var scope = {};
  70 + var uibModal = {
  71 + open: function() { }
  72 + };
  73 +
  74 + $controler('notaPedidoCtrl', {
  75 + $scope: scope,
  76 + $uibModal: uibModal,
  77 + $location: {},
  78 + $filter: filter,
  79 + $timeout: timeout,
  80 + crearNotaPedidoService: {
  81 + getBotonera: function() { },
  82 + getCotizacionByIdMoneda: function() {
  83 + return {
  84 + then: function() { }
  85 + };
  86 + }
  87 + },
  88 + focaBotoneraLateralService: {},
  89 + focaModalService: {},
  90 + notaPedidoBusinessService: {
  91 + plazoToString: function() { },
  92 + calcularArticulos: function() { }
  93 + },
  94 + $rootScope: {
  95 + $on: function() { }
  96 + },
  97 + focaSeguimientoService: {},
  98 + APP: {},
  99 + focaLoginService: {}
  100 + });
  101 + var notaPedido = {
  102 + cotizacion: {
  103 + moneda: {}
  104 + },
  105 + cliente: {},
  106 + vendedor: {},
  107 + proveedor: {},
  108 + notaPedidoPlazo: {},
  109 + notaPedidoPuntoDescarga: []
  110 + };
  111 + var respuesta = { result: Promise.resolve(notaPedido) };
  112 +
  113 + //act
  114 + scope.notaPedido = {};
  115 + scope.$broadcast = function() { };
  116 + spyOn(uibModal, 'open').and.returnValue(respuesta);
  117 + spyOn(scope, '$broadcast');
  118 + scope.seleccionarNotaPedido();
  119 +
  120 + //assert
  121 + respuesta.result.then(function() {
  122 + expect(scope.$broadcast).toHaveBeenCalledWith('removeCabecera', 'Bomba:');
  123 + expect(scope.$broadcast).toHaveBeenCalledWith('removeCabecera', 'Kilometros:');
  124 + done();
  125 + });
  126 + });
  127 +
  128 + it('función seleccionarProductos muestra alerta cuando idLista undefined', function() {
  129 + //arrange
  130 + var scope = {};
  131 + var focaModalService = {
  132 + alert: function() { }
  133 + };
  134 +
  135 + $controler('notaPedidoCtrl', {
  136 + $scope: scope,
  137 + $uibModal: {},
  138 + $location: {},
  139 + $filter: filter,
  140 + $timeout: timeout,
  141 + crearNotaPedidoService: {
  142 + getBotonera: function() { },
  143 + getCotizacionByIdMoneda: function() {
  144 + return {
  145 + then: function() { }
  146 + };
  147 + }
  148 + },
  149 + focaBotoneraLateralService: {},
  150 + focaModalService: focaModalService,
  151 + notaPedidoBusinessService: {},
  152 + $rootScope: {
  153 + $on: function() { }
  154 + },
  155 + focaSeguimientoService: {},
  156 + APP: {},
  157 + focaLoginService: {}
  158 + });
  159 +
  160 + //act
  161 + spyOn(focaModalService, 'alert');
  162 + scope.idLista = undefined;
  163 + scope.seleccionarProductos();
  164 +
  165 + //assert
  166 + expect(focaModalService.alert)
  167 + .toHaveBeenCalledWith('Primero seleccione una lista de precio y condicion');
  168 + });
  169 +
  170 + it('función seleccionarProductos abre modal', function() {
  171 + //arrange
  172 + var scope = {};
  173 + var uibModal = {
  174 + open: function() { }
  175 + };
  176 +
  177 + $controler('notaPedidoCtrl', {
  178 + $scope: scope,
  179 + $uibModal: uibModal,
  180 + $location: {},
  181 + $filter: filter,
  182 + $timeout: timeout,
  183 + crearNotaPedidoService: {
  184 + getBotonera: function() { },
  185 + getCotizacionByIdMoneda: function() {
  186 + return {
  187 + then: function() { }
  188 + };
  189 + }
  190 + },
  191 + focaBotoneraLateralService: {},
  192 + focaModalService: {},
  193 + notaPedidoBusinessService: {},
  194 + $rootScope: {
  195 + $on: function() { }
  196 + },
  197 + focaSeguimientoService: {},
  198 + APP: {},
  199 + focaLoginService: {}
  200 + });
  201 + scope.idLista = true;
  202 + scope.notaPedido = {
  203 + cotizacion: {},
  204 + moneda: {}
  205 + };
  206 + var respuesta = { result: {then: function() { } } };
  207 +
  208 + //act
  209 + spyOn(uibModal, 'open').and.returnValue(respuesta);
  210 + scope.seleccionarProductos();
  211 +
  212 + //assert
  213 + expect(uibModal.open).toHaveBeenCalled();
  214 + });
  215 +
  216 + it('función seleccionarPuntosDeDescarga muestra alerta cuando cliente y domicilio son' +
  217 + 'undefined', function()
  218 + {
  219 + //arrange
  220 + var scope = {};
  221 + var focaModalService = {
  222 + alert: function() { }
  223 + };
  224 +
  225 + $controler('notaPedidoCtrl', {
  226 + $scope: scope,
  227 + $uibModal: {},
  228 + $location: {},
  229 + $filter: filter,
  230 + $timeout: timeout,
  231 + crearNotaPedidoService: {
  232 + getBotonera: function() { },
  233 + getCotizacionByIdMoneda: function() {
  234 + return {
  235 + then: function() { }
  236 + };
  237 + }
  238 + },
  239 + focaBotoneraLateralService: {},
  240 + focaModalService: focaModalService,
  241 + notaPedidoBusinessService: {},
  242 + $rootScope: {
  243 + $on: function() { }
  244 + },
  245 + focaSeguimientoService: {},
  246 + APP: {},
  247 + focaLoginService: {}
  248 + });
  249 + scope.idLista = true;
  250 + scope.notaPedido = {
  251 + cliente: { COD: false },
  252 + domicilio: { id: false}
  253 + };
  254 +
  255 + //act
  256 + spyOn(focaModalService, 'alert');
  257 + scope.seleccionarPuntosDeDescarga();
  258 +
  259 + //assert
  260 + expect(focaModalService.alert).toHaveBeenCalled();
  261 + });
  262 +
  263 + it('función seleccionarPuntosDeDescarga abre modal', function() {
  264 + //arrange
  265 + var scope = {};
  266 + var uibModal = {
  267 + open: function() { }
  268 + };
  269 +
  270 + $controler('notaPedidoCtrl', {
  271 + $scope: scope,
  272 + $uibModal: uibModal,
  273 + $location: {},
  274 + $filter: filter,
  275 + $timeout: timeout,
  276 + crearNotaPedidoService: {
  277 + getBotonera: function() { },
  278 + getCotizacionByIdMoneda: function() {
  279 + return {
  280 + then: function() { }
  281 + };
  282 + }
  283 + },
  284 + focaBotoneraLateralService: {},
  285 + focaModalService: {},
  286 + notaPedidoBusinessService: {},
  287 + $rootScope: {
  288 + $on: function() { }
  289 + },
  290 + focaSeguimientoService: {},
  291 + APP: {},
  292 + focaLoginService: {}
  293 + });
  294 + scope.idLista = true;
  295 + scope.notaPedido = {
  296 + cliente: { COD: true },
  297 + domicilio: { id: true }
  298 + };
  299 + var respuesta = { result: { then: function() { } } };
  300 +
  301 + //act
  302 + spyOn(uibModal, 'open').and.returnValue(respuesta);
  303 + scope.seleccionarPuntosDeDescarga();
  304 +
  305 + //assert
  306 + expect(uibModal.open).toHaveBeenCalled();
  307 + });
  308 +
  309 + it('función seleccionarPuntosDeDescarga setea punto elegido', function(done) {
  310 + //arrange
  311 + var scope = {};
  312 + var uibModal = {
  313 + open: function() { }
  314 + };
  315 +
  316 + $controler('notaPedidoCtrl', {
  317 + $scope: scope,
  318 + $uibModal: uibModal,
  319 + $location: {},
  320 + $filter: filter,
  321 + $timeout: timeout,
  322 + crearNotaPedidoService: {
  323 + getBotonera: function() { },
  324 + getCotizacionByIdMoneda: function() {
  325 + return {
  326 + then: function() { }
  327 + };
  328 + }
  329 + },
  330 + focaBotoneraLateralService: {},
  331 + focaModalService: {},
  332 + notaPedidoBusinessService: {},
  333 + $rootScope: {
  334 + $on: function() { }
  335 + },
  336 + focaSeguimientoService: {},
  337 + APP: {},
  338 + focaLoginService: {}
  339 + });
  340 + scope.idLista = true;
  341 + scope.notaPedido = {
  342 + cliente: { COD: true },
  343 + domicilio: { id: true }
  344 + };
  345 + var respuesta = [];
  346 + var promiseRespuesta = { result: Promise.resolve(respuesta) };
  347 + scope.$broadcast = function() { };
  348 +
  349 + //act
  350 + spyOn(uibModal, 'open').and.returnValue(promiseRespuesta);
  351 + scope.seleccionarPuntosDeDescarga();
  352 +
  353 + //assert
  354 + promiseRespuesta.result.then(function() {
  355 + expect(scope.notaPedido.puntosDescarga).toEqual(respuesta);
  356 + done();
  357 + });
  358 + });
  359 +
  360 + it('función seleccionarVendedor abre modal', function() {
  361 + //arrange
  362 + var scope = {};
  363 + var focaModalService = {
  364 + modal: function() { }
  365 + };
  366 +
  367 + $controler('notaPedidoCtrl', {
  368 + $scope: scope,
  369 + $uibModal: {},
  370 + $location: {},
  371 + $filter: filter,
  372 + $timeout: timeout,
  373 + crearNotaPedidoService: {
  374 + getBotonera: function() { },
  375 + getCotizacionByIdMoneda: function() {
  376 + return {
  377 + then: function() { }
  378 + };
  379 + }
  380 + },
  381 + focaBotoneraLateralService: {},
  382 + focaModalService: focaModalService,
  383 + notaPedidoBusinessService: {},
  384 + $rootScope: {
  385 + $on: function() { }
  386 + },
  387 + focaSeguimientoService: {},
  388 + APP: {},
  389 + focaLoginService: {}
  390 + });
  391 + scope.idLista = true;
  392 + scope.notaPedido = {
  393 + cliente: { COD: true },
  394 + domicilio: { id: true }
  395 + };
  396 +
  397 + var respuesta = { then: function() { } };
  398 +
  399 + //act
  400 + spyOn(focaModalService, 'modal').and.returnValue(respuesta);
  401 + scope.seleccionarVendedor();
  402 +
  403 + //assert
  404 + expect(focaModalService.modal).toHaveBeenCalled();
  405 + });
  406 +
  407 + it('función seleccionarVendedor setea vendedor y cabecera', function(done) {
  408 + //arrange
  409 + var scope = {};
  410 + var focaModalService = {
  411 + modal: function() { }
  412 + };
  413 +
  414 + $controler('notaPedidoCtrl', {
  415 + $scope: scope,
  416 + $uibModal: {},
  417 + $location: {},
  418 + $filter: filter,
  419 + $timeout: timeout,
  420 + crearNotaPedidoService: {
  421 + getBotonera: function() { },
  422 + getCotizacionByIdMoneda: function() {
  423 + return {
  424 + then: function() { }
  425 + };
  426 + }
  427 + },
  428 + focaBotoneraLateralService: {},
  429 + focaModalService: focaModalService,
  430 + notaPedidoBusinessService: {},
  431 + $rootScope: {
  432 + $on: function() { }
  433 + },
  434 + focaSeguimientoService: {},
  435 + APP: {},
  436 + focaLoginService: {}
  437 + });
  438 + scope.idLista = true;
  439 + scope.notaPedido = {
  440 + cliente: { COD: true },
  441 + domicilio: { id: true }
  442 + };
  443 + var respuesta = {};
  444 + var promesaRespuesta = Promise.resolve(respuesta);
  445 + scope.$broadcast = function() { };
  446 +
  447 + //act
  448 + spyOn(focaModalService, 'modal').and.returnValue(promesaRespuesta);
  449 + spyOn(scope, '$broadcast');
  450 + scope.seleccionarVendedor();
  451 +
  452 + //assert
  453 + promesaRespuesta.then(function() {
  454 + expect(scope.notaPedido.vendedor).toEqual(respuesta);
  455 + expect(scope.$broadcast).toHaveBeenCalled();
  456 + done();
  457 + });
  458 + });
  459 +
  460 + it('función seleccionarProveedor abre modal', function() {
  461 + //arrange
  462 + var scope = {};
  463 + var focaModalService = {
  464 + modal: function() { }
  465 + };
  466 +
  467 + $controler('notaPedidoCtrl', {
  468 + $scope: scope,
  469 + $uibModal: {},
  470 + $location: {},
  471 + $filter: filter,
  472 + $timeout: timeout,
  473 + crearNotaPedidoService: {
  474 + getBotonera: function() { },
  475 + getCotizacionByIdMoneda: function() {
  476 + return {
  477 + then: function() { }
  478 + };
  479 + }
  480 + },
  481 + focaBotoneraLateralService: {},
  482 + focaModalService: focaModalService,
  483 + notaPedidoBusinessService: {},
  484 + $rootScope: {
  485 + $on: function() { }
  486 + },
  487 + focaSeguimientoService: {},
  488 + APP: {},
  489 + focaLoginService: {}
  490 + });
  491 + scope.notaPedido = {};
  492 +
  493 + var respuesta = { then: function() { } };
  494 +
  495 + //act
  496 + spyOn(focaModalService, 'modal').and.returnValue(respuesta);
  497 + scope.seleccionarProveedor();
  498 +
  499 + //assert
  500 + expect(focaModalService.modal).toHaveBeenCalled();
  501 + });
  502 +
  503 + it('función seleccionarProveedor setea vendedor y cabecera', function(done) {
  504 + //arrange
  505 + var scope = {};
  506 + var focaModalService = {
  507 + modal: function() { }
  508 + };
  509 +
  510 + $controler('notaPedidoCtrl', {
  511 + $scope: scope,
  512 + $uibModal: {},
  513 + $location: {},
  514 + $filter: filter,
  515 + $timeout: timeout,
  516 + crearNotaPedidoService: {
  517 + getBotonera: function() { },
  518 + getCotizacionByIdMoneda: function() {
  519 + return {
  520 + then: function() { }
  521 + };
  522 + }
  523 + },
  524 + focaBotoneraLateralService: {},
  525 + focaModalService: focaModalService,
  526 + notaPedidoBusinessService: {},
  527 + $rootScope: {
  528 + $on: function() { }
  529 + },
  530 + focaSeguimientoService: {},
  531 + APP: {},
  532 + focaLoginService: {}
  533 + });
  534 +
  535 + scope.notaPedido = {};
  536 + var respuesta = {};
  537 + var promesaRespuesta = Promise.resolve(respuesta);
  538 + scope.$broadcast = function() { };
  539 +
  540 + //act
  541 + spyOn(focaModalService, 'modal').and.returnValue(promesaRespuesta);
  542 + spyOn(scope, '$broadcast');
  543 + scope.seleccionarProveedor();
  544 +
  545 + //assert
  546 + promesaRespuesta.then(function() {
  547 + expect(scope.notaPedido.proveedor).toEqual(respuesta);
  548 + expect(scope.$broadcast).toHaveBeenCalled();
  549 + done();
  550 + });
  551 + });
  552 +
  553 + it('función seleccionarCliente abre alerta cuando no se elije vendedor', function() {
  554 + //arrange
  555 + var scope = {};
  556 + var focaModalService = {
  557 + alert: function() { }
  558 + };
  559 +
  560 + $controler('notaPedidoCtrl', {
  561 + $scope: scope,
  562 + $uibModal: {},
  563 + $location: {},
  564 + $filter: filter,
  565 + $timeout: timeout,
  566 + crearNotaPedidoService: {
  567 + getBotonera: function() { },
  568 + getCotizacionByIdMoneda: function() {
  569 + return {
  570 + then: function() { }
  571 + };
  572 + }
  573 + },
  574 + focaBotoneraLateralService: {},
  575 + focaModalService: focaModalService,
  576 + notaPedidoBusinessService: {},
  577 + $rootScope: {
  578 + $on: function() { }
  579 + },
  580 + focaSeguimientoService: {},
  581 + APP: {},
  582 + focaLoginService: {}
  583 + });
  584 + scope.notaPedido = {
  585 + vendedor: { NUM: false }
  586 + };
  587 +
  588 + //act
  589 + spyOn(focaModalService, 'alert');
  590 + scope.seleccionarCliente();
  591 +
  592 + //assert
  593 + expect(focaModalService.alert).toHaveBeenCalledWith('Primero seleccione un vendedor');
  594 + });
  595 +
  596 + it('función seleccionarCliente abre modal', function() {
  597 + //arrange
  598 + var scope = {};
  599 + var uibModal = {
  600 + open: function() { }
  601 + };
  602 +
  603 + $controler('notaPedidoCtrl', {
  604 + $scope: scope,
  605 + $uibModal: uibModal,
  606 + $location: {},
  607 + $filter: filter,
  608 + $timeout: timeout,
  609 + crearNotaPedidoService: {
  610 + getBotonera: function() { },
  611 + getCotizacionByIdMoneda: function() {
  612 + return {
  613 + then: function() { }
  614 + };
  615 + }
  616 + },
  617 + focaBotoneraLateralService: {},
  618 + focaModalService: {},
  619 + notaPedidoBusinessService: {},
  620 + $rootScope: {
  621 + $on: function() { }
  622 + },
  623 + focaSeguimientoService: {},
  624 + APP: {},
  625 + focaLoginService: {}
  626 + });
  627 + scope.notaPedido = {
  628 + vendedor: { NUM: true }
  629 + };
  630 +
  631 + var respuesta = { result: {then: function() { } } };
  632 +
  633 + //act
  634 + spyOn(uibModal, 'open').and.returnValue(respuesta);
  635 + scope.seleccionarCliente();
  636 +
  637 + //assert
  638 + expect(uibModal.open).toHaveBeenCalled();
  639 + });
  640 +
  641 + it('función seleccionarCliente setea vendedor y llama a domicilios', function(done) {
  642 +
  643 + //arrange
  644 + var scope = {};
  645 + var uibModal = {
  646 + open: function() { }
  647 + };
  648 +
  649 + $controler('notaPedidoCtrl', {
  650 + $scope: scope,
  651 + $uibModal: uibModal,
  652 + $location: {},
  653 + $filter: filter,
  654 + $timeout: timeout,
  655 + crearNotaPedidoService: {
  656 + getBotonera: function() { },
  657 + getCotizacionByIdMoneda: function() {
  658 + return {
  659 + then: function() { }
  660 + };
  661 + }
  662 + },
  663 + focaBotoneraLateralService: {},
  664 + focaModalService: {},
  665 + notaPedidoBusinessService: {},
  666 + $rootScope: {
  667 + $on: function() { }
  668 + },
  669 + focaSeguimientoService: {},
  670 + APP: {},
  671 + focaLoginService: {}
  672 + });
  673 + scope.idLista = true;
  674 + scope.notaPedido = {
  675 + vendedor: { NUM: true }
  676 + };
  677 + var respuesta = {};
  678 + var promesaRespuesta = { result: Promise.resolve(respuesta) };
  679 +
  680 + //act
  681 + spyOn(uibModal, 'open').and.returnValue(promesaRespuesta);
  682 + spyOn(scope, 'abrirModalDomicilios');
  683 + scope.seleccionarCliente();
  684 +
  685 + //assert
  686 + promesaRespuesta.result.then(function() {
  687 + expect(scope.cliente).toEqual(respuesta);
  688 + expect(scope.abrirModalDomicilios).toHaveBeenCalled();
  689 + done();
  690 + });
  691 + });
  692 +
  693 + it('función abrirModalDomicilios abre modal', function() {
  694 + //arrange
  695 + var scope = {};
  696 + var uibModal = {
  697 + open: function() { }
  698 + };
  699 +
  700 + $controler('notaPedidoCtrl', {
  701 + $scope: scope,
  702 + $uibModal: uibModal,
  703 + $location: {},
  704 + $filter: filter,
  705 + $timeout: timeout,
  706 + crearNotaPedidoService: {
  707 + getBotonera: function() { },
  708 + getCotizacionByIdMoneda: function() {
  709 + return {
  710 + then: function() { }
  711 + };
  712 + }
  713 + },
  714 + focaBotoneraLateralService: {},
  715 + focaModalService: {},
  716 + notaPedidoBusinessService: {},
  717 + $rootScope: {
  718 + $on: function() { }
  719 + },
  720 + focaSeguimientoService: {},
  721 + APP: {},
  722 + focaLoginService: {}
  723 + });
  724 +
  725 + var respuesta = { result: {then: function() { } } };
  726 +
  727 + //act
  728 + spyOn(uibModal, 'open').and.returnValue(respuesta);
  729 + scope.abrirModalDomicilios();
  730 +
  731 + //assert
  732 + expect(uibModal.open).toHaveBeenCalled();
  733 + });
  734 +
  735 + it('función abrirModalDomicilios setea domicilio, cliente y cabeceras', function(done) {
  736 +
  737 + //arrange
  738 + var scope = {};
  739 + var uibModal = {
  740 + open: function() { }
  741 + };
  742 +
  743 + $controler('notaPedidoCtrl', {
  744 + $scope: scope,
  745 + $uibModal: uibModal,
  746 + $location: {},
  747 + $filter: filter,
  748 + $timeout: timeout,
  749 + crearNotaPedidoService: {
  750 + getBotonera: function() { },
  751 + getCotizacionByIdMoneda: function() {
  752 + return {
  753 + then: function() { }
  754 + };
  755 + },
  756 + getPuntosDescargaByClienDom: function() {
  757 + return {
  758 + then: function() { }
  759 + };
  760 + }
  761 + },
  762 + focaBotoneraLateralService: {},
  763 + focaModalService: {},
  764 + notaPedidoBusinessService: {},
  765 + $rootScope: {
  766 + $on: function() { }
  767 + },
  768 + focaSeguimientoService: {},
  769 + APP: {},
  770 + focaLoginService: {}
  771 + });
  772 + scope.idLista = true;
  773 + scope.notaPedido = {
  774 + vendedor: { NUM: true }
  775 + };
  776 + var respuesta = {};
  777 + var promesaRespuesta = { result: Promise.resolve(respuesta) };
  778 + scope.$broadcast = function() { };
  779 + var cliente = {
  780 + COD: undefined,
  781 + CUIT: undefined,
  782 + NOM: undefined
  783 + };
  784 +
  785 + //act
  786 + spyOn(uibModal, 'open').and.returnValue(promesaRespuesta);
  787 + spyOn(scope, '$broadcast');
  788 + scope.abrirModalDomicilios({ });
  789 +
  790 + //assert
  791 + promesaRespuesta.result.then(function() {
  792 + expect(scope.notaPedido.domicilio).toEqual(respuesta);
  793 + expect(scope.notaPedido.cliente).toEqual(cliente);
  794 + expect(scope.$broadcast).toHaveBeenCalled();
  795 + done();
  796 + });
  797 + });
  798 +
  799 + it('función getTotal devulve correctamente', function() {
  800 +
  801 + //arrange
  802 + var scope = {};
  803 +
  804 + $controler('notaPedidoCtrl', {
  805 + $scope: scope,
  806 + $uibModal: {},
  807 + $location: {},
  808 + $filter: filter,
  809 + $timeout: timeout,
  810 + crearNotaPedidoService: {
  811 + getBotonera: function() { },
  812 + getCotizacionByIdMoneda: function() {
  813 + return {
  814 + then: function() { }
  815 + };
  816 + }
  817 + },
  818 + focaBotoneraLateralService: {},
  819 + focaModalService: {},
  820 + notaPedidoBusinessService: {},
  821 + $rootScope: {
  822 + $on: function() { }
  823 + },
  824 + focaSeguimientoService: {},
  825 + APP: {},
  826 + focaLoginService: {}
  827 + });
  828 + scope.idLista = true;
  829 + scope.notaPedido = {
  830 + vendedor: { NUM: true }
  831 + };
  832 +
  833 + //act
  834 + scope.articulosTabla = [{ precio: 2, cantidad: 1}];
  835 + var esperado = 2;
  836 + var resultado = scope.getTotal();
  837 +
  838 + //assert
  839 + expect(resultado).toEqual(esperado);
  840 + });
  841 +
  842 + it('función getSubTotal devulve correctamente', function() {
  843 +
  844 + //arrange
  845 + var scope = {};
  846 +
  847 + $controler('notaPedidoCtrl', {
  848 + $scope: scope,
  849 + $uibModal: {},
  850 + $location: {},
  851 + $filter: filter,
  852 + $timeout: timeout,
  853 + crearNotaPedidoService: {
  854 + getBotonera: function() { },
  855 + getCotizacionByIdMoneda: function() {
  856 + return {
  857 + then: function() { }
  858 + };
  859 + }
  860 + },
  861 + focaBotoneraLateralService: {},
  862 + focaModalService: {},
  863 + notaPedidoBusinessService: {},
  864 + $rootScope: {
  865 + $on: function() { }
  866 + },
  867 + focaSeguimientoService: {},
  868 + APP: {},
  869 + focaLoginService: {}
  870 + });
  871 + scope.idLista = true;
  872 + scope.notaPedido = {
  873 + vendedor: { NUM: true }
  874 + };
  875 +
  876 + //act
  877 + scope.articuloACargar = { precio: 2, cantidad: 1};
  878 + var esperado = 2;
  879 + var resultado = scope.getSubTotal();
  880 +
  881 + //assert
  882 + expect(resultado).toEqual(esperado);
  883 + });
  884 +
  885 + it('función seleccionarPreciosYCondiciones abre modal', function() {
  886 +
  887 + //arrange
  888 + var scope = {};
  889 + var uibModal = {
  890 + open: function() { }
  891 + };
  892 +
  893 + $controler('notaPedidoCtrl', {
  894 + $scope: scope,
  895 + $uibModal: uibModal,
  896 + $location: {},
  897 + $filter: filter,
  898 + $timeout: timeout,
  899 + crearNotaPedidoService: {
  900 + getBotonera: function() { },
  901 + getCotizacionByIdMoneda: function() {
  902 + return {
  903 + then: function() { }
  904 + };
  905 + }
  906 + },
  907 + focaBotoneraLateralService: {},
  908 + focaModalService: {},
  909 + notaPedidoBusinessService: {},
  910 + $rootScope: {
  911 + $on: function() { }
  912 + },
  913 + focaSeguimientoService: {},
  914 + APP: {},
  915 + focaLoginService: {}
  916 + });
  917 +
  918 + scope.notaPedido = {};
  919 +
  920 + var respuesta = { result: {then: function() { } } };
  921 +
  922 + //act
  923 + spyOn(uibModal, 'open').and.returnValue(respuesta);
  924 + scope.seleccionarPreciosYCondiciones();
  925 +
  926 + //assert
  927 + expect(uibModal.open).toHaveBeenCalled();
  928 + });
  929 +
  930 + it('función seleccionarPreciosYCondiciones setea articulos y cabecera', function(done) {
  931 +
  932 + //arrange
  933 + var scope = {};
  934 + var uibModal = {
  935 + open: function() { }
  936 + };
  937 +
  938 + $controler('notaPedidoCtrl', {
  939 + $scope: scope,
  940 + $uibModal: uibModal,
  941 + $location: {},
  942 + $filter: filter,
  943 + $timeout: timeout,
  944 + crearNotaPedidoService: {
  945 + getBotonera: function() { },
  946 + getCotizacionByIdMoneda: function() {
  947 + return {
  948 + then: function() { }
  949 + };
  950 + }
  951 + },
  952 + focaBotoneraLateralService: {},
  953 + focaModalService: {},
  954 + notaPedidoBusinessService: {},
  955 + $rootScope: {
  956 + $on: function() { }
  957 + },
  958 + focaSeguimientoService: {},
  959 + APP: {},
  960 + focaLoginService: {}
  961 + });
  962 + scope.idLista = true;
  963 + scope.notaPedido = {
  964 + vendedor: { NUM: true }
  965 + };
  966 + var respuesta = { plazoPago: { } };
  967 + var promesaRespuesta = { result: Promise.resolve(respuesta) };
  968 + scope.$broadcast = function() { };
  969 +
  970 + //act
  971 + spyOn(uibModal, 'open').and.returnValue(promesaRespuesta);
  972 + spyOn(scope, '$broadcast');
  973 + scope.seleccionarPreciosYCondiciones();
  974 +
  975 + //assert
  976 + promesaRespuesta.result.then(function() {
  977 + expect(scope.articulosTabla.length).toEqual(0);
  978 + expect(scope.$broadcast).toHaveBeenCalled();
  979 + done();
  980 + });
  981 + });
  982 +
  983 + it('función seleccionarFlete abre modal', function() {
  984 +
  985 + //arrange
  986 + var scope = {};
  987 + var uibModal = {
  988 + open: function() { }
  989 + };
  990 +
  991 + $controler('notaPedidoCtrl', {
  992 + $scope: scope,
  993 + $uibModal: uibModal,
  994 + $location: {},
  995 + $filter: filter,
  996 + $timeout: timeout,
  997 + crearNotaPedidoService: {
  998 + getBotonera: function() { },
  999 + getCotizacionByIdMoneda: function() {
  1000 + return {
  1001 + then: function() { }
  1002 + };
  1003 + }
  1004 + },
  1005 + focaBotoneraLateralService: {},
  1006 + focaModalService: {},
  1007 + notaPedidoBusinessService: {},
  1008 + $rootScope: {
  1009 + $on: function() { }
  1010 + },
  1011 + focaSeguimientoService: {},
  1012 + APP: {},
  1013 + focaLoginService: {}
  1014 + });
  1015 +
  1016 + scope.notaPedido = {};
  1017 +
  1018 + var respuesta = { result: {then: function() { } } };
  1019 +
  1020 + //act
  1021 + spyOn(uibModal, 'open').and.returnValue(respuesta);
  1022 + scope.seleccionarFlete();
  1023 +
  1024 + //assert
  1025 + expect(uibModal.open).toHaveBeenCalled();
  1026 + });
  1027 +
  1028 + it('función seleccionarFlete setea flete y cabecera', function(done) {
  1029 +
  1030 + //arrange
  1031 + var scope = {};
  1032 + var uibModal = {
  1033 + open: function() { }
  1034 + };
  1035 +
  1036 + $controler('notaPedidoCtrl', {
  1037 + $scope: scope,
  1038 + $uibModal: uibModal,
  1039 + $location: {},
  1040 + $filter: filter,
  1041 + $timeout: timeout,
  1042 + crearNotaPedidoService: {
  1043 + getBotonera: function() { },
  1044 + getCotizacionByIdMoneda: function() {
  1045 + return {
  1046 + then: function() { }
  1047 + };
  1048 + }
  1049 + },
  1050 + focaBotoneraLateralService: {},
  1051 + focaModalService: {},
  1052 + notaPedidoBusinessService: {},
  1053 + $rootScope: {
  1054 + $on: function() { }
  1055 + },
  1056 + focaSeguimientoService: {},
  1057 + APP: {},
  1058 + focaLoginService: {}
  1059 + });
  1060 + scope.idLista = true;
  1061 + scope.notaPedido = {
  1062 + vendedor: { NUM: true }
  1063 + };
  1064 + var respuesta = { flete: 1, FOB: 2, bomba: 3, kilometros: 4 };
  1065 + var promesaRespuesta = { result: Promise.resolve(respuesta) };
  1066 + scope.$broadcast = function() { };
  1067 +
  1068 + //act
  1069 + spyOn(uibModal, 'open').and.returnValue(promesaRespuesta);
  1070 + spyOn(scope, '$broadcast');
  1071 + scope.seleccionarFlete();
  1072 +
  1073 + //assert
  1074 +
  1075 + promesaRespuesta.result.then(function() {
  1076 + expect(scope.notaPedido.flete).toEqual(respuesta.flete);
  1077 + expect(scope.notaPedido.fob).toEqual(respuesta.FOB);
  1078 + expect(scope.notaPedido.bomba).toEqual(respuesta.bomba);
  1079 + expect(scope.notaPedido.kilometros).toEqual(respuesta.kilometros);
  1080 + expect(scope.$broadcast).toHaveBeenCalled();
  1081 + done();
  1082 + });
  1083 + });
  1084 +
  1085 + it('función seleccionarMoneda abre modal', function() {
  1086 + //arrange
  1087 + var scope = {};
  1088 + var focaModalService = {
  1089 + modal: function() { }
  1090 + };
  1091 +
  1092 + $controler('notaPedidoCtrl', {
  1093 + $scope: scope,
  1094 + $uibModal: {},
  1095 + $location: {},
  1096 + $filter: filter,
  1097 + $timeout: timeout,
  1098 + crearNotaPedidoService: {
  1099 + getBotonera: function() { },
  1100 + getCotizacionByIdMoneda: function() {
  1101 + return {
  1102 + then: function() { }
  1103 + };
  1104 + }
  1105 + },
  1106 + focaBotoneraLateralService: {},
  1107 + focaModalService: focaModalService,
  1108 + notaPedidoBusinessService: {},
  1109 + $rootScope: {
  1110 + $on: function() { }
  1111 + },
  1112 + focaSeguimientoService: {},
  1113 + APP: {},
  1114 + focaLoginService: {}
  1115 + });
  1116 + scope.notaPedido = {};
  1117 +
  1118 + var respuesta = { then: function() { } };
  1119 +
  1120 + //act
  1121 + spyOn(focaModalService, 'modal').and.returnValue(respuesta);
  1122 + scope.seleccionarMoneda();
  1123 +
  1124 + //assert
  1125 + expect(focaModalService.modal).toHaveBeenCalled();
  1126 + });
  1127 +
  1128 + it('función seleccionarMoneda llama Modal Cotizacion', function(done) {
  1129 + //arrange
  1130 + var scope = {};
  1131 + var focaModalService = {
  1132 + modal: function() { }
  1133 + };
  1134 +
  1135 + $controler('notaPedidoCtrl', {
  1136 + $scope: scope,
  1137 + $uibModal: {},
  1138 + $location: {},
  1139 + $filter: filter,
  1140 + $timeout: timeout,
  1141 + crearNotaPedidoService: {
  1142 + getBotonera: function() { },
  1143 + getCotizacionByIdMoneda: function() {
  1144 + return {
  1145 + then: function() { }
  1146 + };
  1147 + }
  1148 + },
  1149 + focaBotoneraLateralService: {},
  1150 + focaModalService: focaModalService,
  1151 + notaPedidoBusinessService: {},
  1152 + $rootScope: {
  1153 + $on: function() { }
  1154 + },
  1155 + focaSeguimientoService: {},
  1156 + APP: {},
  1157 + focaLoginService: {}
  1158 + });
  1159 +
  1160 + scope.notaPedido = {};
  1161 + var respuesta = 'test';
  1162 + var promesaRespuesta = Promise.resolve(respuesta);
  1163 +
  1164 + //act
  1165 + spyOn(focaModalService, 'modal').and.returnValue(promesaRespuesta);
  1166 + spyOn(scope, 'abrirModalCotizacion');
  1167 + scope.seleccionarMoneda();
  1168 +
  1169 + //assert
  1170 + promesaRespuesta.then(function() {
  1171 + expect(scope.abrirModalCotizacion).toHaveBeenCalledWith('test');
  1172 + done();
  1173 + });
  1174 + });
  1175 +
  1176 + it('función seleccionarObservaciones llama a prompt', function() {
  1177 +
  1178 + //arrange
  1179 + var scope = {};
  1180 + var focaModalService = {
  1181 + prompt: function() { }
  1182 + };
  1183 +
  1184 + $controler('notaPedidoCtrl', {
  1185 + $scope: scope,
  1186 + $uibModal: {},
  1187 + $location: {},
  1188 + $filter: filter,
  1189 + $timeout: timeout,
  1190 + crearNotaPedidoService: {
  1191 + getBotonera: function() { },
  1192 + getCotizacionByIdMoneda: function() {
  1193 + return {
  1194 + then: function() { }
  1195 + };
  1196 + }
  1197 + },
  1198 + focaBotoneraLateralService: {},
  1199 + focaModalService: focaModalService,
  1200 + notaPedidoBusinessService: {},
  1201 + $rootScope: {
  1202 + $on: function() { }
  1203 + },
  1204 + focaSeguimientoService: {},
  1205 + APP: {},
  1206 + focaLoginService: {}
  1207 + });
  1208 + var respuesta = { then: function() { } };
  1209 + scope.notaPedido = {};
  1210 +
  1211 + //act
  1212 + spyOn(focaModalService, 'prompt').and.returnValue(respuesta);
  1213 + scope.seleccionarObservaciones();
  1214 +
  1215 + //assert
  1216 + expect(focaModalService.prompt).toHaveBeenCalled();
  1217 + });
  1218 +
  1219 + it('función seleccionarObservaciones setea observaciones', function(done) {
  1220 +
  1221 + //arrange
  1222 + var scope = {};
  1223 + var focaModalService = {
  1224 + prompt: function() { }
  1225 + };
  1226 +
  1227 + $controler('notaPedidoCtrl', {
  1228 + $scope: scope,
  1229 + $uibModal: {},
  1230 + $location: {},
  1231 + $filter: filter,
  1232 + $timeout: timeout,
  1233 + crearNotaPedidoService: {
  1234 + getBotonera: function() { },
  1235 + getCotizacionByIdMoneda: function() {
  1236 + return {
  1237 + then: function() { }
  1238 + };
  1239 + }
  1240 + },
  1241 + focaBotoneraLateralService: {},
  1242 + focaModalService: focaModalService,
  1243 + notaPedidoBusinessService: {},
  1244 + $rootScope: {
  1245 + $on: function() { }
  1246 + },
  1247 + focaSeguimientoService: {},
  1248 + APP: {},
  1249 + focaLoginService: {}
  1250 + });
  1251 + var respuesta = 'unit test';
  1252 + var promesa = Promise.resolve(respuesta);
  1253 + scope.notaPedido = {};
  1254 +
  1255 + //act
  1256 + spyOn(focaModalService, 'prompt').and.returnValue(promesa);
  1257 + scope.seleccionarObservaciones();
  1258 +
  1259 + //assert
  1260 + promesa.then(function() {
  1261 + expect(scope.notaPedido.observaciones).toEqual(respuesta);
  1262 + done();
  1263 + });
  1264 + });
  1265 +
  1266 + it('función abrirModalCotizacion abre modal', function() {
  1267 +
  1268 + //arrange
  1269 + var scope = {};
  1270 + var uibModal = {
  1271 + open: function() { }
  1272 + };
  1273 +
  1274 + $controler('notaPedidoCtrl', {
  1275 + $scope: scope,
  1276 + $uibModal: uibModal,
  1277 + $location: {},
  1278 + $filter: filter,
  1279 + $timeout: timeout,
  1280 + crearNotaPedidoService: {
  1281 + getBotonera: function() { },
  1282 + getCotizacionByIdMoneda: function() {
  1283 + return {
  1284 + then: function() { }
  1285 + };
  1286 + }
  1287 + },
  1288 + focaBotoneraLateralService: {},
  1289 + focaModalService: {},
  1290 + notaPedidoBusinessService: {},
  1291 + $rootScope: {
  1292 + $on: function() { }
  1293 + },
  1294 + focaSeguimientoService: {},
  1295 + APP: {},
  1296 + focaLoginService: {}
  1297 + });
  1298 +
  1299 + scope.notaPedido = {};
  1300 +
  1301 + var respuesta = { result: {then: function() { } } };
  1302 +
  1303 + //act
  1304 + spyOn(uibModal, 'open').and.returnValue(respuesta);
  1305 + scope.abrirModalCotizacion();
  1306 +
  1307 + //assert
  1308 + expect(uibModal.open).toHaveBeenCalled();
  1309 + });
  1310 +
  1311 + it('función abrirModalCotizacion setea datos y cabecera', function(done) {
  1312 + //arrange
  1313 + var scope = {};
  1314 + var uibModal = {
  1315 + open: function() { }
  1316 + };
  1317 +
  1318 + $controler('notaPedidoCtrl', {
  1319 + $scope: scope,
  1320 + $uibModal: uibModal,
  1321 + $location: {},
  1322 + $filter: filter,
  1323 + $timeout: timeout,
  1324 + crearNotaPedidoService: {
  1325 + getBotonera: function() { },
  1326 + getCotizacionByIdMoneda: function() {
  1327 + return {
  1328 + then: function() { }
  1329 + };
  1330 + }
  1331 + },
  1332 + focaBotoneraLateralService: {},
  1333 + focaModalService: {},
  1334 + notaPedidoBusinessService: {},
  1335 + $rootScope: {
  1336 + $on: function() { }
  1337 + },
  1338 + focaSeguimientoService: {},
  1339 + APP: {},
  1340 + focaLoginService: {}
  1341 + });
  1342 +
  1343 + scope.notaPedido = {};
  1344 + scope.articulosTabla = [];
  1345 + scope.$broadcast = function() { };
  1346 + var moneda = 'moneda';
  1347 + var cotizacion = 'test';
  1348 + var promesaRespuesta = { result: Promise.resolve(cotizacion) };
  1349 +
  1350 + //act
  1351 + spyOn(uibModal, 'open').and.returnValue(promesaRespuesta);
  1352 + spyOn(scope, '$broadcast');
  1353 + scope.abrirModalCotizacion(moneda);
  1354 +
  1355 + //assert
  1356 + promesaRespuesta.result.then(function() {
  1357 +
  1358 + expect(scope.$broadcast).toHaveBeenCalled();
  1359 + expect(scope.notaPedido.moneda).toEqual(moneda);
  1360 + expect(scope.monedaDefecto).toEqual(moneda);
  1361 + expect(scope.cotizacionDefecto).toEqual(cotizacion);
  1362 + expect(scope.notaPedido.cotizacion).toEqual(cotizacion);
  1363 + done();
  1364 + });
  1365 + });
  1366 +
  1367 + it('función agregarATabla muestra alerta cuando a cargar undefined', function() {
  1368 +
  1369 + //arrange
  1370 + var scope = {};
  1371 + var focaModalService = {
  1372 + alert: function() { }
  1373 + };
  1374 +
  1375 + $controler('notaPedidoCtrl', {
  1376 + $scope: scope,
  1377 + $uibModal: {},
  1378 + $location: {},
  1379 + $filter: filter,
  1380 + $timeout: timeout,
  1381 + crearNotaPedidoService: {
  1382 + getBotonera: function() { },
  1383 + getCotizacionByIdMoneda: function() {
  1384 + return {
  1385 + then: function() { }
  1386 + };
  1387 + }
  1388 + },
  1389 + focaBotoneraLateralService: {},
  1390 + focaModalService: focaModalService,
  1391 + notaPedidoBusinessService: {},
  1392 + $rootScope: {
  1393 + $on: function() { }
  1394 + },
  1395 + focaSeguimientoService: {},
  1396 + APP: {},
  1397 + focaLoginService: {}
  1398 + });
  1399 + scope.articuloACargar = {};
  1400 +
  1401 + //act
  1402 + spyOn(focaModalService, 'alert');
  1403 + scope.agregarATabla(13);
  1404 +
  1405 + //assert
  1406 + expect(focaModalService.alert).toHaveBeenCalledWith('El valor debe ser al menos 1');
  1407 + });
  1408 +
  1409 + it('función editarArticulo muestra alerta cuando a cargar es undefined', function() {
  1410 +
  1411 + //arrange
  1412 + var scope = {};
  1413 + var focaModalService = {
  1414 + alert: function() { }
  1415 + };
  1416 +
  1417 + $controler('notaPedidoCtrl', {
  1418 + $scope: scope,
  1419 + $uibModal: {},
  1420 + $location: {},
  1421 + $filter: filter,
  1422 + $timeout: timeout,
  1423 + crearNotaPedidoService: {
  1424 + getBotonera: function() { },
  1425 + getCotizacionByIdMoneda: function() {
  1426 + return {
  1427 + then: function() { }
  1428 + };
  1429 + }
  1430 + },
  1431 + focaBotoneraLateralService: {},
  1432 + focaModalService: focaModalService,
  1433 + notaPedidoBusinessService: {},
  1434 + $rootScope: {
  1435 + $on: function() { }
  1436 + },
  1437 + focaSeguimientoService: {},
  1438 + APP: {},
  1439 + focaLoginService: {}
  1440 + });
  1441 + scope.articuloACargar = {};
  1442 +
  1443 + //act
  1444 + spyOn(focaModalService, 'alert');
  1445 + scope.agregarATabla(13);
  1446 +
  1447 + //assert
  1448 + expect(focaModalService.alert).toHaveBeenCalledWith('El valor debe ser al menos 1');
  1449 + });
  1450 +
  1451 + it('función salir lleva a ruta correcta', function() {
  1452 +
  1453 + inject(function($location) {
  1454 +
  1455 + //arrange
  1456 + var scope = {};
  1457 +
  1458 + $controler('notaPedidoCtrl', {
  1459 + $scope: scope,
  1460 + $uibModal: {},
  1461 + $location: $location,
  1462 + $filter: filter,
  1463 + $timeout: timeout,
  1464 + crearNotaPedidoService: {
  1465 + getBotonera: function() { },
  1466 + getCotizacionByIdMoneda: function() {
  1467 + return {
  1468 + then: function() { }
  1469 + };
  1470 + }
  1471 + },
  1472 + focaBotoneraLateralService: {},
  1473 + focaModalService: {},
  1474 + notaPedidoBusinessService: {},
  1475 + $rootScope: {
  1476 + $on: function() { }
  1477 + },
  1478 + focaSeguimientoService: {},
  1479 + APP: {},
  1480 + focaLoginService: {}
  1481 + });
  1482 +
  1483 + //act
  1484 + scope.salir();
  1485 +
  1486 + //assert
  1487 + expect($location.url()).toEqual('/');
  1488 + });
  1489 + });
  1490 + });
  1491 +});
spec/controllerSpecCrearPedido.js
... ... @@ -0,0 +1,738 @@
  1 +describe('Controladores módulo crear nota de pedido', function() {
  2 +
  3 + var $controler;
  4 +
  5 + beforeEach(function() {
  6 + module('focaCrearNotaPedido');
  7 + inject(function(_$controller_) {
  8 + $controler = _$controller_;
  9 + });
  10 + });
  11 +
  12 + describe('Controlador notaPedidoCtrl crear nota de pedido', function() {
  13 +
  14 + var filter = function() {
  15 + return function() { };
  16 + };
  17 + var timeout;
  18 +
  19 + beforeEach(function() {
  20 +
  21 + inject(function($timeout) {
  22 + timeout = $timeout;
  23 + });
  24 + });
  25 +
  26 + it('Existe el controlador notaPedidoCtrl', function() {
  27 +
  28 + //act
  29 + var controlador = $controler('notaPedidoCtrl', {
  30 + $scope: {},
  31 + $uibModal: {},
  32 + $location: {},
  33 + $filter: filter,
  34 + $timeout: timeout,
  35 + crearNotaPedidoService: {
  36 + getBotonera: function() { },
  37 + getCotizacionByIdMoneda: function() {
  38 + return {
  39 + then: function() {}
  40 + };
  41 + }
  42 + },
  43 + focaBotoneraLateralService: {},
  44 + focaModalService: {},
  45 + notaPedidoBusinessService: {},
  46 + $rootScope: {
  47 + $on: function() { }
  48 + },
  49 + focaSeguimientoService: {},
  50 + APP: {},
  51 + focaLoginService: {}
  52 + });
  53 +
  54 + //expect
  55 + expect(typeof controlador).toEqual('object');
  56 + });
  57 +
  58 + it('la funcion $scope.crearNotaPedido muestra alerta cuando vendedor es null', function() {
  59 +
  60 + //arrange
  61 + var scope = {};
  62 + var focaModalService = {
  63 + alert: function() { }
  64 + };
  65 +
  66 + $controler('notaPedidoCtrl', {
  67 + $scope: scope,
  68 + $uibModal: {},
  69 + $location: {},
  70 + $filter: filter,
  71 + $timeout: timeout,
  72 + crearNotaPedidoService: {
  73 + getBotonera: function() { },
  74 + getCotizacionByIdMoneda: function() {
  75 + return {
  76 + then: function() {}
  77 + };
  78 + }
  79 + },
  80 + focaBotoneraLateralService: {},
  81 + focaModalService: focaModalService,
  82 + notaPedidoBusinessService: {},
  83 + $rootScope: {
  84 + $on: function() { }
  85 + },
  86 + focaSeguimientoService: {},
  87 + APP: {},
  88 + focaLoginService: {}
  89 + });
  90 +
  91 + //act
  92 + scope.notaPedido = {
  93 + vendedor: {
  94 + id: null
  95 + }
  96 + };
  97 + spyOn(focaModalService, 'alert');
  98 + scope.crearNotaPedido();
  99 +
  100 + //expect
  101 + expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Vendedor');
  102 + });
  103 +
  104 + it('la funcion $scope.crearNotaPedido muestra alerta cuando cliente es null', function() {
  105 +
  106 + //arrange
  107 + var scope = {};
  108 + var focaModalService = {
  109 + alert: function() { }
  110 + };
  111 +
  112 + $controler('notaPedidoCtrl', {
  113 + $scope: scope,
  114 + $uibModal: {},
  115 + $location: {},
  116 + $filter: filter,
  117 + $timeout: timeout,
  118 + crearNotaPedidoService: {
  119 + getBotonera: function() { },
  120 + getCotizacionByIdMoneda: function() {
  121 + return {
  122 + then: function() {}
  123 + };
  124 + }
  125 + },
  126 + focaBotoneraLateralService: {},
  127 + focaModalService: focaModalService,
  128 + notaPedidoBusinessService: {},
  129 + $rootScope: {
  130 + $on: function() { }
  131 + },
  132 + focaSeguimientoService: {},
  133 + APP: {},
  134 + focaLoginService: {}
  135 + });
  136 +
  137 + scope.notaPedido = {
  138 + vendedor: {
  139 + id: true
  140 + },
  141 + cliente:{
  142 + COD: false
  143 + }
  144 + };
  145 +
  146 + //act
  147 + spyOn(focaModalService, 'alert');
  148 + scope.crearNotaPedido();
  149 +
  150 + //expect
  151 + expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Cliente');
  152 + });
  153 +
  154 + it('funcion $scope.crearNotaPedido muestra alerta cuando proveedor es null', function() {
  155 +
  156 + //arrange
  157 + var scope = {};
  158 + var focaModalService = {
  159 + alert: function() { }
  160 + };
  161 +
  162 + $controler('notaPedidoCtrl', {
  163 + $scope: scope,
  164 + $uibModal: {},
  165 + $location: {},
  166 + $filter: filter,
  167 + $timeout: timeout,
  168 + crearNotaPedidoService: {
  169 + getBotonera: function() { },
  170 + getCotizacionByIdMoneda: function() {
  171 + return {
  172 + then: function() {}
  173 + };
  174 + }
  175 + },
  176 + focaBotoneraLateralService: {},
  177 + focaModalService: focaModalService,
  178 + notaPedidoBusinessService: {},
  179 + $rootScope: {
  180 + $on: function() { }
  181 + },
  182 + focaSeguimientoService: {},
  183 + APP: {},
  184 + focaLoginService: {}
  185 + });
  186 +
  187 + scope.notaPedido = {
  188 + vendedor: {
  189 + id: true
  190 + },
  191 + cliente:{
  192 + COD: true
  193 + },
  194 + proveedor:{
  195 + COD: null
  196 + }
  197 + };
  198 +
  199 + //act
  200 + spyOn(focaModalService, 'alert');
  201 + scope.crearNotaPedido();
  202 +
  203 + //expect
  204 + expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Proveedor');
  205 + });
  206 +
  207 + it('funcion $scope.crearNotaPedido muestra alerta cuando Moneda es null', function() {
  208 +
  209 + //arrange
  210 + var scope = {};
  211 + var focaModalService = {
  212 + alert: function() { }
  213 + };
  214 +
  215 + $controler('notaPedidoCtrl', {
  216 + $scope: scope,
  217 + $uibModal: {},
  218 + $location: {},
  219 + $filter: filter,
  220 + $timeout: timeout,
  221 + crearNotaPedidoService: {
  222 + getBotonera: function() { },
  223 + getCotizacionByIdMoneda: function() {
  224 + return {
  225 + then: function() {}
  226 + };
  227 + }
  228 + },
  229 + focaBotoneraLateralService: {},
  230 + focaModalService: focaModalService,
  231 + notaPedidoBusinessService: {},
  232 + $rootScope: {
  233 + $on: function() { }
  234 + },
  235 + focaSeguimientoService: {},
  236 + APP: {},
  237 + focaLoginService: {}
  238 + });
  239 +
  240 + scope.notaPedido = {
  241 + vendedor: {
  242 + id: true
  243 + },
  244 + cliente:{
  245 + COD: true
  246 + },
  247 + proveedor:{
  248 + COD: true
  249 + },
  250 + moneda:{
  251 + ID: null
  252 + }
  253 + };
  254 +
  255 + //act
  256 + spyOn(focaModalService, 'alert');
  257 + scope.crearNotaPedido();
  258 +
  259 + //expect
  260 + expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Moneda');
  261 + });
  262 +
  263 + it('funcion $scope.crearNotaPedido muestra alerta cuando cotizacion es null', function() {
  264 +
  265 + //arrange
  266 + var scope = {};
  267 + var focaModalService = {
  268 + alert: function() { }
  269 + };
  270 +
  271 + $controler('notaPedidoCtrl', {
  272 + $scope: scope,
  273 + $uibModal: {},
  274 + $location: {},
  275 + $filter: filter,
  276 + $timeout: timeout,
  277 + crearNotaPedidoService: {
  278 + getBotonera: function() { },
  279 + getCotizacionByIdMoneda: function() {
  280 + return {
  281 + then: function() {}
  282 + };
  283 + }
  284 + },
  285 + focaBotoneraLateralService: {},
  286 + focaModalService: focaModalService,
  287 + notaPedidoBusinessService: {},
  288 + $rootScope: {
  289 + $on: function() { }
  290 + },
  291 + focaSeguimientoService: {},
  292 + APP: {},
  293 + focaLoginService: {}
  294 + });
  295 +
  296 + scope.notaPedido = {
  297 + vendedor: {
  298 + id: true
  299 + },
  300 + cliente:{
  301 + COD: true
  302 + },
  303 + proveedor:{
  304 + COD: true
  305 + },
  306 + moneda:{
  307 + ID: true
  308 + },
  309 + cotizacion:{
  310 + ID: null
  311 + }
  312 + };
  313 +
  314 + //act
  315 + spyOn(focaModalService, 'alert');
  316 + scope.crearNotaPedido();
  317 +
  318 + //expect
  319 + expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Cotización');
  320 + });
  321 +
  322 + it('funcion $scope.crearNotaPedido muestra alerta cuando plazos es null', function() {
  323 +
  324 + //arrange
  325 + var scope = {};
  326 + var focaModalService = {
  327 + alert: function() { }
  328 + };
  329 +
  330 + $controler('notaPedidoCtrl', {
  331 + $scope: scope,
  332 + $uibModal: {},
  333 + $location: {},
  334 + $filter: filter,
  335 + $timeout: timeout,
  336 + crearNotaPedidoService: {
  337 + getBotonera: function() { },
  338 + getCotizacionByIdMoneda: function() {
  339 + return {
  340 + then: function() {}
  341 + };
  342 + }
  343 + },
  344 + focaBotoneraLateralService: {},
  345 + focaModalService: focaModalService,
  346 + notaPedidoBusinessService: {},
  347 + $rootScope: {
  348 + $on: function() { }
  349 + },
  350 + focaSeguimientoService: {},
  351 + APP: {},
  352 + focaLoginService: {}
  353 + });
  354 +
  355 + scope.notaPedido = {
  356 + vendedor: {
  357 + id: true
  358 + },
  359 + cliente:{
  360 + COD: true
  361 + },
  362 + proveedor:{
  363 + COD: true
  364 + },
  365 + moneda:{
  366 + ID: true
  367 + },
  368 + cotizacion:{
  369 + ID: true
  370 + }
  371 + };
  372 +
  373 + scope.plazosPagos = null;
  374 +
  375 + //act
  376 + spyOn(focaModalService, 'alert');
  377 + scope.crearNotaPedido();
  378 +
  379 + //expect
  380 + expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Precios y Condiciones');
  381 + });
  382 +
  383 + it('funcion $scope.crearNotaPedido muestra alerta cuando flete es null', function() {
  384 +
  385 + //arrange
  386 + var scope = {};
  387 + var focaModalService = {
  388 + alert: function() { }
  389 + };
  390 +
  391 + $controler('notaPedidoCtrl', {
  392 + $scope: scope,
  393 + $uibModal: {},
  394 + $location: {},
  395 + $filter: filter,
  396 + $timeout: timeout,
  397 + crearNotaPedidoService: {
  398 + getBotonera: function() { },
  399 + getCotizacionByIdMoneda: function() {
  400 + return {
  401 + then: function() {}
  402 + };
  403 + }
  404 + },
  405 + focaBotoneraLateralService: {},
  406 + focaModalService: focaModalService,
  407 + notaPedidoBusinessService: {},
  408 + $rootScope: {
  409 + $on: function() { }
  410 + },
  411 + focaSeguimientoService: {},
  412 + APP: {},
  413 + focaLoginService: {}
  414 + });
  415 +
  416 + scope.notaPedido = {
  417 + vendedor: {
  418 + id: true
  419 + },
  420 + cliente:{
  421 + COD: true
  422 + },
  423 + proveedor:{
  424 + COD: true
  425 + },
  426 + moneda:{
  427 + ID: true
  428 + },
  429 + cotizacion:{
  430 + ID: true
  431 + },
  432 + flete: null
  433 + };
  434 +
  435 + scope.plazosPagos = true;
  436 +
  437 + //act
  438 + spyOn(focaModalService, 'alert');
  439 + scope.crearNotaPedido();
  440 +
  441 + //expect
  442 + expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Flete');
  443 + });
  444 +
  445 + it('funcion $scope.crearNotaPedido muestra alerta cuando domicilio es null', function() {
  446 +
  447 + //arrange
  448 + var scope = {};
  449 + var focaModalService = {
  450 + alert: function() { }
  451 + };
  452 +
  453 + $controler('notaPedidoCtrl', {
  454 + $scope: scope,
  455 + $uibModal: {},
  456 + $location: {},
  457 + $filter: filter,
  458 + $timeout: timeout,
  459 + crearNotaPedidoService: {
  460 + getBotonera: function() { },
  461 + getCotizacionByIdMoneda: function() {
  462 + return {
  463 + then: function() {}
  464 + };
  465 + }
  466 + },
  467 + focaBotoneraLateralService: {},
  468 + focaModalService: focaModalService,
  469 + notaPedidoBusinessService: {},
  470 + $rootScope: {
  471 + $on: function() { }
  472 + },
  473 + focaSeguimientoService: {},
  474 + APP: {},
  475 + focaLoginService: {}
  476 + });
  477 +
  478 + scope.notaPedido = {
  479 + vendedor: {
  480 + id: true
  481 + },
  482 + cliente:{
  483 + COD: true
  484 + },
  485 + proveedor:{
  486 + COD: true
  487 + },
  488 + moneda:{
  489 + ID: true
  490 + },
  491 + cotizacion:{
  492 + ID: true
  493 + },
  494 + flete: true,
  495 + domicilioStamp: null
  496 + };
  497 +
  498 + scope.plazosPagos = true;
  499 +
  500 + //act
  501 + spyOn(focaModalService, 'alert');
  502 + scope.crearNotaPedido();
  503 +
  504 + //expect
  505 + expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Domicilio');
  506 + });
  507 +
  508 + it('funcion $scope.crearNotaPedido muestra alerta cuando no se cargaron articulos',
  509 + function()
  510 + {
  511 +
  512 + //arrange
  513 + var scope = {};
  514 + var focaModalService = {
  515 + alert: function() { }
  516 + };
  517 +
  518 + $controler('notaPedidoCtrl', {
  519 + $scope: scope,
  520 + $uibModal: {},
  521 + $location: {},
  522 + $filter: filter,
  523 + $timeout: timeout,
  524 + crearNotaPedidoService: {
  525 + getBotonera: function() { },
  526 + getCotizacionByIdMoneda: function() {
  527 + return {
  528 + then: function() {}
  529 + };
  530 + }
  531 + },
  532 + focaBotoneraLateralService: {},
  533 + focaModalService: focaModalService,
  534 + notaPedidoBusinessService: {},
  535 + $rootScope: {
  536 + $on: function() { }
  537 + },
  538 + focaSeguimientoService: {},
  539 + APP: {},
  540 + focaLoginService: {}
  541 + });
  542 +
  543 + scope.notaPedido = {
  544 + vendedor: {
  545 + id: true
  546 + },
  547 + cliente:{
  548 + COD: true
  549 + },
  550 + proveedor:{
  551 + COD: true
  552 + },
  553 + moneda:{
  554 + ID: true
  555 + },
  556 + cotizacion:{
  557 + ID: true
  558 + },
  559 + flete: true,
  560 + domicilioStamp: true,
  561 + };
  562 +
  563 + scope.plazosPagos = true;
  564 + scope.articulosTabla = [];
  565 +
  566 + //act
  567 + spyOn(focaModalService, 'alert');
  568 + scope.crearNotaPedido();
  569 +
  570 + //expect
  571 + expect(focaModalService.alert)
  572 + .toHaveBeenCalledWith('Debe cargar al menos un articulo');
  573 + });
  574 +
  575 + it('funcion $scope.crearNotaPedido llama startGuardar', function() {
  576 +
  577 + //arrange
  578 + var scope = {};
  579 + var focaBotoneraLateralService = {
  580 + startGuardar: function() { }
  581 + };
  582 +
  583 + $controler('notaPedidoCtrl', {
  584 + $scope: scope,
  585 + $uibModal: {},
  586 + $location: {},
  587 + $filter: filter,
  588 + $timeout: timeout,
  589 + crearNotaPedidoService: {
  590 + getBotonera: function() { },
  591 + getCotizacionByIdMoneda: function() {
  592 + return {
  593 + then: function() {}
  594 + };
  595 + },
  596 + crearNotaPedido: function() {
  597 + return {
  598 + then: function() { }
  599 + };
  600 + }
  601 + },
  602 + focaBotoneraLateralService: focaBotoneraLateralService,
  603 + focaModalService: {},
  604 + notaPedidoBusinessService: {},
  605 + $rootScope: {
  606 + $on: function() { }
  607 + },
  608 + focaSeguimientoService: {},
  609 + APP: {},
  610 + focaLoginService: {}
  611 + });
  612 +
  613 + scope.notaPedido = {
  614 + vendedor: {
  615 + id: true
  616 + },
  617 + cliente:{
  618 + COD: true
  619 + },
  620 + proveedor:{
  621 + COD: true
  622 + },
  623 + moneda:{
  624 + ID: true
  625 + },
  626 + cotizacion:{
  627 + ID: true
  628 + },
  629 + flete: true,
  630 + domicilioStamp: true,
  631 + domicilio: {
  632 + id: true
  633 + }
  634 + };
  635 +
  636 + scope.plazosPagos = true;
  637 + scope.articulosTabla = [1];
  638 +
  639 + //act
  640 + spyOn(focaBotoneraLateralService, 'startGuardar');
  641 + scope.crearNotaPedido();
  642 +
  643 + //expect
  644 + expect(focaBotoneraLateralService.startGuardar).toHaveBeenCalled();
  645 + });
  646 +
  647 + it('funcion $scope.crearNotaPedido llama funciones al guardar', function(done) {
  648 +
  649 + //arrange
  650 + var scope = {};
  651 + var focaBotoneraLateralService = {
  652 + startGuardar: function() { },
  653 + endGuardar: function() { }
  654 + };
  655 + var focaSeguimientoService = {
  656 + guardarPosicion: function() { }
  657 + };
  658 + var notaPedidoBusinessService = {
  659 + addArticulos: function() { },
  660 + addEstado: function() { }
  661 + };
  662 + var crearNotaPedidoService = {
  663 + getBotonera: function() { },
  664 + getCotizacionByIdMoneda: function() {
  665 + return {
  666 + then: function() {}
  667 + };
  668 + },
  669 + crearNotaPedido: function() { },
  670 + getNumeroNotaPedido: function() {
  671 + return {
  672 + then: function() { }
  673 + };
  674 + }
  675 + };
  676 +
  677 + $controler('notaPedidoCtrl', {
  678 + $scope: scope,
  679 + $uibModal: {},
  680 + $location: {},
  681 + $filter: filter,
  682 + $timeout: timeout,
  683 + crearNotaPedidoService: crearNotaPedidoService,
  684 + focaBotoneraLateralService: focaBotoneraLateralService,
  685 + focaModalService: {},
  686 + notaPedidoBusinessService: notaPedidoBusinessService,
  687 + $rootScope: {
  688 + $on: function() { }
  689 + },
  690 + focaSeguimientoService: focaSeguimientoService,
  691 + APP: {},
  692 + focaLoginService: {}
  693 + });
  694 +
  695 + scope.notaPedido = {
  696 + vendedor: {
  697 + id: true
  698 + },
  699 + cliente:{
  700 + COD: true
  701 + },
  702 + proveedor:{
  703 + COD: true
  704 + },
  705 + moneda:{
  706 + ID: true
  707 + },
  708 + cotizacion:{
  709 + ID: true
  710 + },
  711 + flete: true,
  712 + domicilioStamp: true,
  713 + domicilio: {
  714 + id: true
  715 + }
  716 + };
  717 +
  718 + scope.plazosPagos = [];
  719 + scope.articulosTabla = [1];
  720 +
  721 + var promesa = Promise.resolve({ data: 1 });
  722 + scope.$broadcast = function() { };
  723 +
  724 + //act
  725 + spyOn(crearNotaPedidoService, 'crearNotaPedido').and.returnValue(promesa);
  726 + spyOn(focaSeguimientoService, 'guardarPosicion');
  727 + spyOn(notaPedidoBusinessService, 'addArticulos');
  728 + scope.crearNotaPedido();
  729 +
  730 + //expect
  731 + promesa.then(function() {
  732 + expect(focaSeguimientoService.guardarPosicion).toHaveBeenCalled();
  733 + expect(notaPedidoBusinessService.addArticulos).toHaveBeenCalled();
  734 + done();
  735 + });
  736 + });
  737 + });
  738 +});
... ... @@ -0,0 +1,19 @@
  1 +describe('Rutas del módulo crear nota de pedido', function() {
  2 +
  3 + var route;
  4 +
  5 + beforeEach(function() {
  6 + module('focaCrearNotaPedido');
  7 + inject(function($route) {
  8 + route = $route;
  9 + });
  10 + });
  11 +
  12 + it('la ruta /venta-nota-pedido/crear dirige correctamente', function() {
  13 + //expect
  14 + expect(route.routes['/venta-nota-pedido/crear'].controller)
  15 + .toBe('notaPedidoCtrl');
  16 + expect(route.routes['/venta-nota-pedido/crear'].templateUrl)
  17 + .toBe('src/views/nota-pedido.html');
  18 + });
  19 +});
... ... @@ -0,0 +1,377 @@
  1 +describe('Servicios módulo crear nota de pedido', function() {
  2 +
  3 + beforeEach(function() {
  4 + module('focaCrearNotaPedido');
  5 + });
  6 +
  7 + describe('servicios crearNotaPedidoService', function() {
  8 +
  9 + var servicio, httpBackend;
  10 +
  11 + beforeEach(function() {
  12 +
  13 + inject(module(function($provide) {
  14 + $provide.value('API_ENDPOINT', {
  15 + URL: 'localhost'
  16 + });
  17 + }));
  18 +
  19 + inject(function(_crearNotaPedidoService_, $httpBackend) {
  20 + servicio = _crearNotaPedidoService_;
  21 + httpBackend = $httpBackend;
  22 + });
  23 + });
  24 +
  25 + it('Existe el servicio crearNotaPedidoService', function() {
  26 + //assert
  27 + expect(typeof servicio).toEqual('object');
  28 + });
  29 +
  30 + it('la función crearNotaPedido lleva la ruta correcta', function() {
  31 + //arrange
  32 + var responseFake = { data: 'test'};
  33 + var result;
  34 + var bodyFake = 1;
  35 + httpBackend.expectPOST('localhost/nota-pedido', { notaPedido: bodyFake })
  36 + .respond(responseFake);
  37 +
  38 + //act
  39 + servicio.crearNotaPedido(bodyFake).then(function(data) {
  40 + result = data.data;
  41 + });
  42 + httpBackend.flush();
  43 +
  44 + //assert
  45 + expect(result).toEqual(responseFake);
  46 + });
  47 +
  48 + it('la función obtenerNotaPedido lleva la ruta correcta', function() {
  49 + //arrange
  50 + var responseFake = { data: 'test'};
  51 + var result;
  52 + httpBackend.expectGET('localhost/nota-pedido').respond(responseFake);
  53 +
  54 + //act
  55 + servicio.obtenerNotaPedido().then(function(data) {
  56 + result = data.data;
  57 + });
  58 + httpBackend.flush();
  59 +
  60 + //assert
  61 + expect(result).toEqual(responseFake);
  62 + });
  63 +
  64 + it('la función setNotaPedido setea nota pedido', function() {
  65 + //arrange
  66 + var paramFake = 1;
  67 +
  68 + //act
  69 + servicio.setNotaPedido(paramFake);
  70 +
  71 + //assert
  72 + expect(servicio.notaPedido).toEqual(paramFake);
  73 + });
  74 +
  75 + it('la función clearNotaPedido setea nota pedido undefined', function() {
  76 +
  77 + //act
  78 + servicio.clearNotaPedido();
  79 +
  80 + //assert
  81 + expect(servicio.notaPedido).toEqual(undefined);
  82 + });
  83 +
  84 + it('la función clearNotaPedido setea nota pedido undefined', function() {
  85 + //arrange
  86 + var paramFake = 1;
  87 +
  88 + //act
  89 + servicio.setNotaPedido(paramFake);
  90 + var result = servicio.getNotaPedido();
  91 +
  92 + //assert
  93 + expect(result).toEqual(paramFake);
  94 + });
  95 +
  96 + it('la funcion getArticulosByIdNotaPedido llama a la ruta correcta', function() {
  97 +
  98 + //arrange
  99 + var responseFake = { data: 'test'};
  100 + var result;
  101 + var paramFake = 1;
  102 + httpBackend.expectGET('localhost/articulos/nota-pedido/' + paramFake)
  103 + .respond(responseFake);
  104 +
  105 + //act
  106 + servicio.getArticulosByIdNotaPedido(paramFake).then(function(data) {
  107 + result = data.data;
  108 + });
  109 + httpBackend.flush();
  110 +
  111 + //assert
  112 + expect(result).toEqual(responseFake);
  113 + });
  114 +
  115 + it('la funcion crearArticulosParaNotaPedido llama a la ruta correcta', function() {
  116 +
  117 + //arrange
  118 + var responseFake = { data: 'test'};
  119 + var result;
  120 + var paramFake = 1;
  121 + httpBackend.expectPOST('localhost/articulos/nota-pedido',
  122 + {articuloNotaPedido: paramFake}).respond(responseFake);
  123 +
  124 + //act
  125 + servicio.crearArticulosParaNotaPedido(paramFake).then(function(data) {
  126 + result = data.data;
  127 + });
  128 + httpBackend.flush();
  129 +
  130 + //assert
  131 + expect(result).toEqual(responseFake);
  132 + });
  133 +
  134 + it('la funcion getDomiciliosByIdNotaPedido llama a la ruta correcta', function() {
  135 +
  136 + //arrange
  137 + var responseFake = { data: 'test'};
  138 + var result;
  139 + var paramFake = 1;
  140 + httpBackend.expectGET('localhost/nota-pedido/' + paramFake + '/domicilios')
  141 + .respond(responseFake);
  142 +
  143 + //act
  144 + servicio.getDomiciliosByIdNotaPedido(paramFake).then(function(data) {
  145 + result = data.data;
  146 + });
  147 + httpBackend.flush();
  148 +
  149 + //assert
  150 + expect(result).toEqual(responseFake);
  151 + });
  152 +
  153 + it('la funcion getDomiciliosByIdCliente llama a la ruta correcta', function() {
  154 +
  155 + //arrange
  156 + var responseFake = { data: 'test'};
  157 + var result;
  158 + var paramFake = 1;
  159 + httpBackend.expectGET('localhost/domicilio/tipo/2/cliente/' + paramFake )
  160 + .respond(responseFake);
  161 +
  162 + //act
  163 + servicio.getDomiciliosByIdCliente(paramFake).then(function(data) {
  164 + result = data.data;
  165 + });
  166 + httpBackend.flush();
  167 +
  168 + //assert
  169 + expect(result).toEqual(responseFake);
  170 + });
  171 +
  172 + it('la funcion getPrecioCondicion llama a la ruta correcta', function() {
  173 +
  174 + //arrange
  175 + var responseFake = { data: 'test'};
  176 + var result;
  177 + httpBackend.expectGET('localhost/precio-condicion').respond(responseFake);
  178 +
  179 + //act
  180 + servicio.getPrecioCondicion().then(function(data) {
  181 + result = data.data;
  182 + });
  183 + httpBackend.flush();
  184 +
  185 + //assert
  186 + expect(result).toEqual(responseFake);
  187 + });
  188 +
  189 + it('la funcion getPrecioCondicionById llama a la ruta correcta', function() {
  190 +
  191 + //arrange
  192 + var responseFake = { data: 'test'};
  193 + var result;
  194 + var paramFake = 1;
  195 + httpBackend.expectGET('localhost/precio-condicion/' + paramFake).respond(responseFake);
  196 +
  197 + //act
  198 + servicio.getPrecioCondicionById(paramFake).then(function(data) {
  199 + result = data.data;
  200 + });
  201 + httpBackend.flush();
  202 +
  203 + //assert
  204 + expect(result).toEqual(responseFake);
  205 + });
  206 +
  207 + it('la funcion getPlazoPagoByPrecioCondicion llama a la ruta correcta', function() {
  208 +
  209 + //arrange
  210 + var responseFake = { data: 'test'};
  211 + var result;
  212 + var paramFake = 1;
  213 + httpBackend.expectGET('localhost/plazo-pago/precio-condicion/' + paramFake)
  214 + .respond(responseFake);
  215 +
  216 + //act
  217 + servicio.getPlazoPagoByPrecioCondicion(paramFake).then(function(data) {
  218 + result = data.data;
  219 + });
  220 + httpBackend.flush();
  221 +
  222 + //assert
  223 + expect(result).toEqual(responseFake);
  224 + });
  225 +
  226 + it('la funcion crearFlete llama a la ruta correcta', function() {
  227 +
  228 + //arrange
  229 + var responseFake = { data: 'test'};
  230 + var result;
  231 + var paramFake = 1;
  232 + httpBackend.expectPOST('localhost/flete', { flete: paramFake })
  233 + .respond(responseFake);
  234 +
  235 + //act
  236 + servicio.crearFlete(paramFake).then(function(data) {
  237 + result = data.data;
  238 + });
  239 + httpBackend.flush();
  240 +
  241 + //assert
  242 + expect(result).toEqual(responseFake);
  243 + });
  244 +
  245 + it('la funcion crearPlazosParaNotaPedido llama a la ruta correcta', function() {
  246 +
  247 + //arrange
  248 + var responseFake = { data: 'test'};
  249 + var result;
  250 + var paramFake = 1;
  251 + httpBackend.expectPOST('localhost/plazo-pago/nota-pedido', { plazos: paramFake })
  252 + .respond(responseFake);
  253 +
  254 + //act
  255 + servicio.crearPlazosParaNotaPedido(paramFake).then(function(data) {
  256 + result = data.data;
  257 + });
  258 + httpBackend.flush();
  259 +
  260 + //assert
  261 + expect(result).toEqual(responseFake);
  262 + });
  263 +
  264 + it('la funcion getCotizacionByIdMoneda llama a la ruta correcta', function() {
  265 +
  266 + //arrange
  267 + var responseFake = { data: 'test'};
  268 + var result;
  269 + var paramFake = 1;
  270 + httpBackend.expectGET('localhost/moneda/' + paramFake).respond(responseFake);
  271 +
  272 + //act
  273 + servicio.getCotizacionByIdMoneda(paramFake).then(function(data) {
  274 + result = data.data;
  275 + });
  276 + httpBackend.flush();
  277 +
  278 + //assert
  279 + expect(result).toEqual(responseFake);
  280 + });
  281 +
  282 + it('la funcion crearEstadoParaNotaPedido llama a la ruta correcta', function() {
  283 +
  284 + //arrange
  285 + var responseFake = { data: 'test'};
  286 + var result;
  287 + var paramFake = 1;
  288 + httpBackend.expectPOST('localhost/estado', { estado: paramFake })
  289 + .respond(responseFake);
  290 +
  291 + //act
  292 + servicio.crearEstadoParaNotaPedido(paramFake).then(function(data) {
  293 + result = data.data;
  294 + });
  295 + httpBackend.flush();
  296 +
  297 + //assert
  298 + expect(result).toEqual(responseFake);
  299 + });
  300 +
  301 + it('la funcion getNumeroNotaPedido llama a la ruta correcta', function() {
  302 +
  303 + //arrange
  304 + var responseFake = { data: 'test'};
  305 + var result;
  306 + httpBackend.expectGET('localhost/nota-pedido/numero-siguiente').respond(responseFake);
  307 +
  308 + //act
  309 + servicio.getNumeroNotaPedido().then(function(data) {
  310 + result = data.data;
  311 + });
  312 + httpBackend.flush();
  313 +
  314 + //assert
  315 + expect(result).toEqual(responseFake);
  316 + });
  317 +
  318 + it('la funcion crearPuntosDescarga llama a la ruta correcta', function() {
  319 +
  320 + //arrange
  321 + var responseFake = { data: 'test'};
  322 + var result;
  323 + var paramFake = 1;
  324 + httpBackend.expectPOST('localhost/puntos-descarga/nota-pedido',
  325 + { puntosDescarga: paramFake }).respond(responseFake);
  326 +
  327 + //act
  328 + servicio.crearPuntosDescarga(paramFake).then(function(data) {
  329 + result = data.data;
  330 + });
  331 + httpBackend.flush();
  332 +
  333 + //assert
  334 + expect(result).toEqual(responseFake);
  335 + });
  336 +
  337 + it('la funcion getPuntosDescargaByClienDom llama a la ruta correcta', function() {
  338 +
  339 + //arrange
  340 + var responseFake = { data: 'test'};
  341 + var result;
  342 + var paramFake = 1;
  343 + var paramFake2 = 1;
  344 + httpBackend.expectGET('localhost/punto-descarga/' + paramFake + '/' + paramFake2)
  345 + .respond(responseFake);
  346 +
  347 + //act
  348 + servicio.getPuntosDescargaByClienDom(paramFake, paramFake2).then(function(data) {
  349 + result = data.data;
  350 + });
  351 + httpBackend.flush();
  352 +
  353 + //assert
  354 + expect(result).toEqual(responseFake);
  355 + });
  356 +
  357 + it('la funcion getVendedorById llama a la ruta correcta', function() {
  358 +
  359 + //arrange
  360 + var responseFake = { data: 'test'};
  361 + var result;
  362 + var paramFake = 1;
  363 + httpBackend.expectGET('localhost/vendedor-cobrador/' + paramFake)
  364 + .respond(responseFake);
  365 +
  366 + //act
  367 + servicio.getVendedorById(paramFake).then(function(data) {
  368 + result = data.data;
  369 + });
  370 + httpBackend.flush();
  371 +
  372 + //assert
  373 + expect(result).toEqual(responseFake);
  374 + });
  375 +
  376 + });
  377 +});
1   -angular.module('focaCrearNotaPedido', []);
  1 +angular.module('focaCrearNotaPedido', ['ngRoute']);
src/js/controller.js
... ... @@ -49,12 +49,12 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
49 49 } else {
50 50 $scope.botonera = crearNotaPedidoService.getBotonera();
51 51 }
52   -
  52 +
53 53 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]'
54 54 crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) {
55 55 $scope.monedaDefecto = res.data[0];
56 56 $scope.cotizacionDefecto = $scope.monedaDefecto.cotizaciones[0];
57   -
  57 +
58 58 init();
59 59 });
60 60 }
... ... @@ -71,7 +71,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
71 71 moneda: $scope.monedaDefecto,
72 72 cotizacion: $scope.cotizacionDefecto
73 73 };
74   -
  74 +
75 75 $scope.articulosTabla = [];
76 76 $scope.idLista = undefined;
77 77  
... ... @@ -194,7 +194,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
194 194 dias: plazo.dias
195 195 });
196 196 });
197   -
  197 +
198 198 if (plazosACrear.length) {
199 199 crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear);
200 200 }
... ... @@ -204,7 +204,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
204 204  
205 205 focaBotoneraLateralService.endGuardar(true);
206 206 $scope.saveLoading = false;
207   -
  207 +
208 208 init();
209 209 }, function(error) {
210 210 focaModalService.alert('Hubo un error al crear la nota de pedido');
... ... @@ -308,7 +308,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
308 308 }
309 309 cabeceras.push(cabeceraBomba);
310 310 }
311   -
  311 +
312 312 $scope.articulosTabla = notaPedido.articulosNotaPedido;
313 313 notaPedidoBusinessService.calcularArticulos($scope.articulosTabla,
314 314 notaPedido.cotizacion.VENDEDOR);
... ... @@ -318,15 +318,15 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
318 318 } else {
319 319 $scope.idLista = -1;
320 320 }
321   -
  321 +
322 322 $scope.puntoVenta = $filter('rellenarDigitos')(
323 323 notaPedido.sucursal, 4
324 324 );
325   -
  325 +
326 326 $scope.comprobante = $filter('rellenarDigitos')(
327 327 notaPedido.numeroNotaPedido, 8
328 328 );
329   -
  329 +
330 330 $scope.notaPedido = notaPedido;
331 331 $scope.notaPedido.moneda = notaPedido.cotizacion.moneda;
332 332 $scope.plazosPagos = notaPedido.notaPedidoPlazo;
... ... @@ -767,14 +767,14 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
767 767 modalInstance.result.then(
768 768 function(cotizacion) {
769 769 var articulosTablaTemp = $scope.articulosTabla;
770   -
  770 +
771 771 for(var i = 0; i < articulosTablaTemp.length; i++) {
772 772 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio *
773 773 $scope.notaPedido.cotizacion.VENDEDOR;
774 774 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio /
775 775 cotizacion.VENDEDOR;
776 776 }
777   -
  777 +
778 778 $scope.articulosTabla = articulosTablaTemp;
779 779 $scope.notaPedido.moneda = moneda;
780 780 $scope.monedaDefecto = moneda;
1 1 angular.module('focaCrearNotaPedido')
2   - .service('crearNotaPedidoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) {
  2 + .factory('crearNotaPedidoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) {
3 3 var route = API_ENDPOINT.URL;
4 4 return {
5 5 crearNotaPedido: function(notaPedido) {
... ... @@ -86,7 +86,7 @@ angular.module(&#39;focaCrearNotaPedido&#39;)
86 86 image: 'productos.png'
87 87 }
88 88 ];
89   -
  89 +
90 90 if(!vendedor) {
91 91 var botonVendedor = {
92 92 label: 'Vendedor',
... ... @@ -0,0 +1,22 @@
  1 +<html>
  2 + <head>
  3 + <link rel="stylesheet" type="text/css" href="node_modules/jasmine-core/lib/jasmine-core/jasmine.css">
  4 + <meta charset="UTF-8" />
  5 + </head>
  6 + <body>
  7 + <script type="text/javascript" src="node_modules/jasmine-core/lib/jasmine-core/jasmine.js"></script>
  8 + <script type="text/javascript" src="node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js"></script>
  9 + <script type="text/javascript" src="node_modules/jasmine-core/lib/jasmine-core/boot.js"></script>
  10 + <script type="text/javascript" src="node_modules/angular/angular.min.js"></script>
  11 + <script type="text/javascript" src="node_modules/angular-route/angular-route.min.js"></script>
  12 + <script type="text/javascript" src="node_modules/angular-mocks/angular-mocks.js"></script>
  13 + <script type="text/javascript" src="src/js/app.js"></script>
  14 + <script type="text/javascript" src="src/js/controller.js"></script>
  15 + <script type="text/javascript" src="src/js/service.js"></script>
  16 + <script type="text/javascript" src="src/js/route.js"></script>
  17 + <script type="text/javascript" src="spec/controllerSpec.js"></script>
  18 + <script type="text/javascript" src="spec/controllerSpecCrearPedido.js"></script>
  19 + <script type="text/javascript" src="spec/serviceSpec.js"></script>
  20 + <script type="text/javascript" src="spec/routeSpec.js"></script>
  21 + </body>
  22 +</html>