Commit 1a30061d01a0b8256f2a30aec6b0de1dfaa4e14e

Authored by Jose Pinto
1 parent a24ce94ee3
Exists in master and in 1 other branch develop

semicolon

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