Commit 96b605083a30b7a1ddcb2f01f3c4406495b552ae
1 parent
2b34686915
Exists in
master
linea al final
Showing
1 changed file
with
1 additions
and
1 deletions
Show diff stats
spec/controllerSpecCrearPedido.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 crear nota de pedido', function() { | 12 | describe('Controlador notaPedidoCtrl crear nota de pedido', 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('Existe el controlador notaPedidoCtrl', function() { | 26 | it('Existe el controlador notaPedidoCtrl', function() { |
27 | 27 | ||
28 | //act | 28 | //act |
29 | var controlador = $controler('notaPedidoCtrl', { | 29 | var controlador = $controler('notaPedidoCtrl', { |
30 | $scope: {}, | 30 | $scope: {}, |
31 | $uibModal: {}, | 31 | $uibModal: {}, |
32 | $location: {}, | 32 | $location: {}, |
33 | $filter: filter, | 33 | $filter: filter, |
34 | $timeout: timeout, | 34 | $timeout: timeout, |
35 | crearNotaPedidoService: { | 35 | crearNotaPedidoService: { |
36 | getBotonera: function() { }, | 36 | getBotonera: function() { }, |
37 | getCotizacionByIdMoneda: function() { | 37 | getCotizacionByIdMoneda: function() { |
38 | return { | 38 | return { |
39 | then: function() {} | 39 | then: function() {} |
40 | }; | 40 | }; |
41 | } | 41 | } |
42 | }, | 42 | }, |
43 | focaBotoneraLateralService: {}, | 43 | focaBotoneraLateralService: {}, |
44 | focaModalService: {}, | 44 | focaModalService: {}, |
45 | notaPedidoBusinessService: {}, | 45 | notaPedidoBusinessService: {}, |
46 | $rootScope: { | 46 | $rootScope: { |
47 | $on: function() { } | 47 | $on: function() { } |
48 | }, | 48 | }, |
49 | focaSeguimientoService: {}, | 49 | focaSeguimientoService: {}, |
50 | APP: {}, | 50 | APP: {}, |
51 | focaLoginService: {} | 51 | focaLoginService: {} |
52 | }); | 52 | }); |
53 | 53 | ||
54 | //expect | 54 | //expect |
55 | expect(typeof controlador).toEqual('object'); | 55 | expect(typeof controlador).toEqual('object'); |
56 | }); | 56 | }); |
57 | 57 | ||
58 | it('la funcion $scope.crearNotaPedido muestra alerta cuando vendedor es null', function() { | 58 | it('la funcion $scope.crearNotaPedido muestra alerta cuando vendedor es null', function() { |
59 | 59 | ||
60 | //arrange | 60 | //arrange |
61 | var scope = {}; | 61 | var scope = {}; |
62 | var focaModalService = { | 62 | var focaModalService = { |
63 | alert: function() { } | 63 | alert: function() { } |
64 | }; | 64 | }; |
65 | 65 | ||
66 | $controler('notaPedidoCtrl', { | 66 | $controler('notaPedidoCtrl', { |
67 | $scope: scope, | 67 | $scope: scope, |
68 | $uibModal: {}, | 68 | $uibModal: {}, |
69 | $location: {}, | 69 | $location: {}, |
70 | $filter: filter, | 70 | $filter: filter, |
71 | $timeout: timeout, | 71 | $timeout: timeout, |
72 | crearNotaPedidoService: { | 72 | crearNotaPedidoService: { |
73 | getBotonera: function() { }, | 73 | getBotonera: function() { }, |
74 | getCotizacionByIdMoneda: function() { | 74 | getCotizacionByIdMoneda: function() { |
75 | return { | 75 | return { |
76 | then: function() {} | 76 | then: function() {} |
77 | }; | 77 | }; |
78 | } | 78 | } |
79 | }, | 79 | }, |
80 | focaBotoneraLateralService: {}, | 80 | focaBotoneraLateralService: {}, |
81 | focaModalService: focaModalService, | 81 | focaModalService: focaModalService, |
82 | notaPedidoBusinessService: {}, | 82 | notaPedidoBusinessService: {}, |
83 | $rootScope: { | 83 | $rootScope: { |
84 | $on: function() { } | 84 | $on: function() { } |
85 | }, | 85 | }, |
86 | focaSeguimientoService: {}, | 86 | focaSeguimientoService: {}, |
87 | APP: {}, | 87 | APP: {}, |
88 | focaLoginService: {} | 88 | focaLoginService: {} |
89 | }); | 89 | }); |
90 | 90 | ||
91 | //act | 91 | //act |
92 | scope.notaPedido = { | 92 | scope.notaPedido = { |
93 | vendedor: { | 93 | vendedor: { |
94 | id: null | 94 | id: null |
95 | } | 95 | } |
96 | }; | 96 | }; |
97 | spyOn(focaModalService, 'alert'); | 97 | spyOn(focaModalService, 'alert'); |
98 | scope.crearNotaPedido(); | 98 | scope.crearNotaPedido(); |
99 | 99 | ||
100 | //expect | 100 | //expect |
101 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Vendedor'); | 101 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Vendedor'); |
102 | }); | 102 | }); |
103 | 103 | ||
104 | it('la funcion $scope.crearNotaPedido muestra alerta cuando cliente es null', function() { | 104 | it('la funcion $scope.crearNotaPedido muestra alerta cuando cliente es null', function() { |
105 | 105 | ||
106 | //arrange | 106 | //arrange |
107 | var scope = {}; | 107 | var scope = {}; |
108 | var focaModalService = { | 108 | var focaModalService = { |
109 | alert: function() { } | 109 | alert: function() { } |
110 | }; | 110 | }; |
111 | 111 | ||
112 | $controler('notaPedidoCtrl', { | 112 | $controler('notaPedidoCtrl', { |
113 | $scope: scope, | 113 | $scope: scope, |
114 | $uibModal: {}, | 114 | $uibModal: {}, |
115 | $location: {}, | 115 | $location: {}, |
116 | $filter: filter, | 116 | $filter: filter, |
117 | $timeout: timeout, | 117 | $timeout: timeout, |
118 | crearNotaPedidoService: { | 118 | crearNotaPedidoService: { |
119 | getBotonera: function() { }, | 119 | getBotonera: function() { }, |
120 | getCotizacionByIdMoneda: function() { | 120 | getCotizacionByIdMoneda: function() { |
121 | return { | 121 | return { |
122 | then: function() {} | 122 | then: function() {} |
123 | }; | 123 | }; |
124 | } | 124 | } |
125 | }, | 125 | }, |
126 | focaBotoneraLateralService: {}, | 126 | focaBotoneraLateralService: {}, |
127 | focaModalService: focaModalService, | 127 | focaModalService: focaModalService, |
128 | notaPedidoBusinessService: {}, | 128 | notaPedidoBusinessService: {}, |
129 | $rootScope: { | 129 | $rootScope: { |
130 | $on: function() { } | 130 | $on: function() { } |
131 | }, | 131 | }, |
132 | focaSeguimientoService: {}, | 132 | focaSeguimientoService: {}, |
133 | APP: {}, | 133 | APP: {}, |
134 | focaLoginService: {} | 134 | focaLoginService: {} |
135 | }); | 135 | }); |
136 | 136 | ||
137 | scope.notaPedido = { | 137 | scope.notaPedido = { |
138 | vendedor: { | 138 | vendedor: { |
139 | id: true | 139 | id: true |
140 | }, | 140 | }, |
141 | cliente:{ | 141 | cliente:{ |
142 | COD: false | 142 | COD: false |
143 | } | 143 | } |
144 | }; | 144 | }; |
145 | 145 | ||
146 | //act | 146 | //act |
147 | spyOn(focaModalService, 'alert'); | 147 | spyOn(focaModalService, 'alert'); |
148 | scope.crearNotaPedido(); | 148 | scope.crearNotaPedido(); |
149 | 149 | ||
150 | //expect | 150 | //expect |
151 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Cliente'); | 151 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Cliente'); |
152 | }); | 152 | }); |
153 | 153 | ||
154 | it('funcion $scope.crearNotaPedido muestra alerta cuando proveedor es null', function() { | 154 | it('funcion $scope.crearNotaPedido muestra alerta cuando proveedor es null', function() { |
155 | 155 | ||
156 | //arrange | 156 | //arrange |
157 | var scope = {}; | 157 | var scope = {}; |
158 | var focaModalService = { | 158 | var focaModalService = { |
159 | alert: function() { } | 159 | alert: function() { } |
160 | }; | 160 | }; |
161 | 161 | ||
162 | $controler('notaPedidoCtrl', { | 162 | $controler('notaPedidoCtrl', { |
163 | $scope: scope, | 163 | $scope: scope, |
164 | $uibModal: {}, | 164 | $uibModal: {}, |
165 | $location: {}, | 165 | $location: {}, |
166 | $filter: filter, | 166 | $filter: filter, |
167 | $timeout: timeout, | 167 | $timeout: timeout, |
168 | crearNotaPedidoService: { | 168 | crearNotaPedidoService: { |
169 | getBotonera: function() { }, | 169 | getBotonera: function() { }, |
170 | getCotizacionByIdMoneda: function() { | 170 | getCotizacionByIdMoneda: function() { |
171 | return { | 171 | return { |
172 | then: function() {} | 172 | then: function() {} |
173 | }; | 173 | }; |
174 | } | 174 | } |
175 | }, | 175 | }, |
176 | focaBotoneraLateralService: {}, | 176 | focaBotoneraLateralService: {}, |
177 | focaModalService: focaModalService, | 177 | focaModalService: focaModalService, |
178 | notaPedidoBusinessService: {}, | 178 | notaPedidoBusinessService: {}, |
179 | $rootScope: { | 179 | $rootScope: { |
180 | $on: function() { } | 180 | $on: function() { } |
181 | }, | 181 | }, |
182 | focaSeguimientoService: {}, | 182 | focaSeguimientoService: {}, |
183 | APP: {}, | 183 | APP: {}, |
184 | focaLoginService: {} | 184 | focaLoginService: {} |
185 | }); | 185 | }); |
186 | 186 | ||
187 | scope.notaPedido = { | 187 | scope.notaPedido = { |
188 | vendedor: { | 188 | vendedor: { |
189 | id: true | 189 | id: true |
190 | }, | 190 | }, |
191 | cliente:{ | 191 | cliente:{ |
192 | COD: true | 192 | COD: true |
193 | }, | 193 | }, |
194 | proveedor:{ | 194 | proveedor:{ |
195 | COD: null | 195 | COD: null |
196 | } | 196 | } |
197 | }; | 197 | }; |
198 | 198 | ||
199 | //act | 199 | //act |
200 | spyOn(focaModalService, 'alert'); | 200 | spyOn(focaModalService, 'alert'); |
201 | scope.crearNotaPedido(); | 201 | scope.crearNotaPedido(); |
202 | 202 | ||
203 | //expect | 203 | //expect |
204 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Proveedor'); | 204 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Proveedor'); |
205 | }); | 205 | }); |
206 | 206 | ||
207 | it('funcion $scope.crearNotaPedido muestra alerta cuando Moneda es null', function() { | 207 | it('funcion $scope.crearNotaPedido muestra alerta cuando Moneda es null', function() { |
208 | 208 | ||
209 | //arrange | 209 | //arrange |
210 | var scope = {}; | 210 | var scope = {}; |
211 | var focaModalService = { | 211 | var focaModalService = { |
212 | alert: function() { } | 212 | alert: function() { } |
213 | }; | 213 | }; |
214 | 214 | ||
215 | $controler('notaPedidoCtrl', { | 215 | $controler('notaPedidoCtrl', { |
216 | $scope: scope, | 216 | $scope: scope, |
217 | $uibModal: {}, | 217 | $uibModal: {}, |
218 | $location: {}, | 218 | $location: {}, |
219 | $filter: filter, | 219 | $filter: filter, |
220 | $timeout: timeout, | 220 | $timeout: timeout, |
221 | crearNotaPedidoService: { | 221 | crearNotaPedidoService: { |
222 | getBotonera: function() { }, | 222 | getBotonera: function() { }, |
223 | getCotizacionByIdMoneda: function() { | 223 | getCotizacionByIdMoneda: function() { |
224 | return { | 224 | return { |
225 | then: function() {} | 225 | then: function() {} |
226 | }; | 226 | }; |
227 | } | 227 | } |
228 | }, | 228 | }, |
229 | focaBotoneraLateralService: {}, | 229 | focaBotoneraLateralService: {}, |
230 | focaModalService: focaModalService, | 230 | focaModalService: focaModalService, |
231 | notaPedidoBusinessService: {}, | 231 | notaPedidoBusinessService: {}, |
232 | $rootScope: { | 232 | $rootScope: { |
233 | $on: function() { } | 233 | $on: function() { } |
234 | }, | 234 | }, |
235 | focaSeguimientoService: {}, | 235 | focaSeguimientoService: {}, |
236 | APP: {}, | 236 | APP: {}, |
237 | focaLoginService: {} | 237 | focaLoginService: {} |
238 | }); | 238 | }); |
239 | 239 | ||
240 | scope.notaPedido = { | 240 | scope.notaPedido = { |
241 | vendedor: { | 241 | vendedor: { |
242 | id: true | 242 | id: true |
243 | }, | 243 | }, |
244 | cliente:{ | 244 | cliente:{ |
245 | COD: true | 245 | COD: true |
246 | }, | 246 | }, |
247 | proveedor:{ | 247 | proveedor:{ |
248 | COD: true | 248 | COD: true |
249 | }, | 249 | }, |
250 | moneda:{ | 250 | moneda:{ |
251 | ID: null | 251 | ID: null |
252 | } | 252 | } |
253 | }; | 253 | }; |
254 | 254 | ||
255 | //act | 255 | //act |
256 | spyOn(focaModalService, 'alert'); | 256 | spyOn(focaModalService, 'alert'); |
257 | scope.crearNotaPedido(); | 257 | scope.crearNotaPedido(); |
258 | 258 | ||
259 | //expect | 259 | //expect |
260 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Moneda'); | 260 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Moneda'); |
261 | }); | 261 | }); |
262 | 262 | ||
263 | it('funcion $scope.crearNotaPedido muestra alerta cuando cotizacion es null', function() { | 263 | it('funcion $scope.crearNotaPedido muestra alerta cuando cotizacion es null', function() { |
264 | 264 | ||
265 | //arrange | 265 | //arrange |
266 | var scope = {}; | 266 | var scope = {}; |
267 | var focaModalService = { | 267 | var focaModalService = { |
268 | alert: function() { } | 268 | alert: function() { } |
269 | }; | 269 | }; |
270 | 270 | ||
271 | $controler('notaPedidoCtrl', { | 271 | $controler('notaPedidoCtrl', { |
272 | $scope: scope, | 272 | $scope: scope, |
273 | $uibModal: {}, | 273 | $uibModal: {}, |
274 | $location: {}, | 274 | $location: {}, |
275 | $filter: filter, | 275 | $filter: filter, |
276 | $timeout: timeout, | 276 | $timeout: timeout, |
277 | crearNotaPedidoService: { | 277 | crearNotaPedidoService: { |
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 | }); | 294 | }); |
295 | 295 | ||
296 | scope.notaPedido = { | 296 | scope.notaPedido = { |
297 | vendedor: { | 297 | vendedor: { |
298 | id: true | 298 | id: true |
299 | }, | 299 | }, |
300 | cliente:{ | 300 | cliente:{ |
301 | COD: true | 301 | COD: true |
302 | }, | 302 | }, |
303 | proveedor:{ | 303 | proveedor:{ |
304 | COD: true | 304 | COD: true |
305 | }, | 305 | }, |
306 | moneda:{ | 306 | moneda:{ |
307 | ID: true | 307 | ID: true |
308 | }, | 308 | }, |
309 | cotizacion:{ | 309 | cotizacion:{ |
310 | ID: null | 310 | ID: null |
311 | } | 311 | } |
312 | }; | 312 | }; |
313 | 313 | ||
314 | //act | 314 | //act |
315 | spyOn(focaModalService, 'alert'); | 315 | spyOn(focaModalService, 'alert'); |
316 | scope.crearNotaPedido(); | 316 | scope.crearNotaPedido(); |
317 | 317 | ||
318 | //expect | 318 | //expect |
319 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Cotización'); | 319 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Cotización'); |
320 | }); | 320 | }); |
321 | 321 | ||
322 | it('funcion $scope.crearNotaPedido muestra alerta cuando plazos es null', function() { | 322 | it('funcion $scope.crearNotaPedido muestra alerta cuando plazos es null', function() { |
323 | 323 | ||
324 | //arrange | 324 | //arrange |
325 | var scope = {}; | 325 | var scope = {}; |
326 | var focaModalService = { | 326 | var focaModalService = { |
327 | alert: function() { } | 327 | alert: function() { } |
328 | }; | 328 | }; |
329 | 329 | ||
330 | $controler('notaPedidoCtrl', { | 330 | $controler('notaPedidoCtrl', { |
331 | $scope: scope, | 331 | $scope: scope, |
332 | $uibModal: {}, | 332 | $uibModal: {}, |
333 | $location: {}, | 333 | $location: {}, |
334 | $filter: filter, | 334 | $filter: filter, |
335 | $timeout: timeout, | 335 | $timeout: timeout, |
336 | crearNotaPedidoService: { | 336 | crearNotaPedidoService: { |
337 | getBotonera: function() { }, | 337 | getBotonera: function() { }, |
338 | getCotizacionByIdMoneda: function() { | 338 | getCotizacionByIdMoneda: function() { |
339 | return { | 339 | return { |
340 | then: function() {} | 340 | then: function() {} |
341 | }; | 341 | }; |
342 | } | 342 | } |
343 | }, | 343 | }, |
344 | focaBotoneraLateralService: {}, | 344 | focaBotoneraLateralService: {}, |
345 | focaModalService: focaModalService, | 345 | focaModalService: focaModalService, |
346 | notaPedidoBusinessService: {}, | 346 | notaPedidoBusinessService: {}, |
347 | $rootScope: { | 347 | $rootScope: { |
348 | $on: function() { } | 348 | $on: function() { } |
349 | }, | 349 | }, |
350 | focaSeguimientoService: {}, | 350 | focaSeguimientoService: {}, |
351 | APP: {}, | 351 | APP: {}, |
352 | focaLoginService: {} | 352 | focaLoginService: {} |
353 | }); | 353 | }); |
354 | 354 | ||
355 | scope.notaPedido = { | 355 | scope.notaPedido = { |
356 | vendedor: { | 356 | vendedor: { |
357 | id: true | 357 | id: true |
358 | }, | 358 | }, |
359 | cliente:{ | 359 | cliente:{ |
360 | COD: true | 360 | COD: true |
361 | }, | 361 | }, |
362 | proveedor:{ | 362 | proveedor:{ |
363 | COD: true | 363 | COD: true |
364 | }, | 364 | }, |
365 | moneda:{ | 365 | moneda:{ |
366 | ID: true | 366 | ID: true |
367 | }, | 367 | }, |
368 | cotizacion:{ | 368 | cotizacion:{ |
369 | ID: true | 369 | ID: true |
370 | } | 370 | } |
371 | }; | 371 | }; |
372 | 372 | ||
373 | scope.plazosPagos = null; | 373 | scope.plazosPagos = null; |
374 | 374 | ||
375 | //act | 375 | //act |
376 | spyOn(focaModalService, 'alert'); | 376 | spyOn(focaModalService, 'alert'); |
377 | scope.crearNotaPedido(); | 377 | scope.crearNotaPedido(); |
378 | 378 | ||
379 | //expect | 379 | //expect |
380 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Precios y Condiciones'); | 380 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Precios y Condiciones'); |
381 | }); | 381 | }); |
382 | 382 | ||
383 | it('funcion $scope.crearNotaPedido muestra alerta cuando flete es null', function() { | 383 | it('funcion $scope.crearNotaPedido muestra alerta cuando flete es null', function() { |
384 | 384 | ||
385 | //arrange | 385 | //arrange |
386 | var scope = {}; | 386 | var scope = {}; |
387 | var focaModalService = { | 387 | var focaModalService = { |
388 | alert: function() { } | 388 | alert: function() { } |
389 | }; | 389 | }; |
390 | 390 | ||
391 | $controler('notaPedidoCtrl', { | 391 | $controler('notaPedidoCtrl', { |
392 | $scope: scope, | 392 | $scope: scope, |
393 | $uibModal: {}, | 393 | $uibModal: {}, |
394 | $location: {}, | 394 | $location: {}, |
395 | $filter: filter, | 395 | $filter: filter, |
396 | $timeout: timeout, | 396 | $timeout: timeout, |
397 | crearNotaPedidoService: { | 397 | crearNotaPedidoService: { |
398 | getBotonera: function() { }, | 398 | getBotonera: function() { }, |
399 | getCotizacionByIdMoneda: function() { | 399 | getCotizacionByIdMoneda: function() { |
400 | return { | 400 | return { |
401 | then: function() {} | 401 | then: function() {} |
402 | }; | 402 | }; |
403 | } | 403 | } |
404 | }, | 404 | }, |
405 | focaBotoneraLateralService: {}, | 405 | focaBotoneraLateralService: {}, |
406 | focaModalService: focaModalService, | 406 | focaModalService: focaModalService, |
407 | notaPedidoBusinessService: {}, | 407 | notaPedidoBusinessService: {}, |
408 | $rootScope: { | 408 | $rootScope: { |
409 | $on: function() { } | 409 | $on: function() { } |
410 | }, | 410 | }, |
411 | focaSeguimientoService: {}, | 411 | focaSeguimientoService: {}, |
412 | APP: {}, | 412 | APP: {}, |
413 | focaLoginService: {} | 413 | focaLoginService: {} |
414 | }); | 414 | }); |
415 | 415 | ||
416 | scope.notaPedido = { | 416 | scope.notaPedido = { |
417 | vendedor: { | 417 | vendedor: { |
418 | id: true | 418 | id: true |
419 | }, | 419 | }, |
420 | cliente:{ | 420 | cliente:{ |
421 | COD: true | 421 | COD: true |
422 | }, | 422 | }, |
423 | proveedor:{ | 423 | proveedor:{ |
424 | COD: true | 424 | COD: true |
425 | }, | 425 | }, |
426 | moneda:{ | 426 | moneda:{ |
427 | ID: true | 427 | ID: true |
428 | }, | 428 | }, |
429 | cotizacion:{ | 429 | cotizacion:{ |
430 | ID: true | 430 | ID: true |
431 | }, | 431 | }, |
432 | flete: null | 432 | flete: null |
433 | }; | 433 | }; |
434 | 434 | ||
435 | scope.plazosPagos = true; | 435 | scope.plazosPagos = true; |
436 | 436 | ||
437 | //act | 437 | //act |
438 | spyOn(focaModalService, 'alert'); | 438 | spyOn(focaModalService, 'alert'); |
439 | scope.crearNotaPedido(); | 439 | scope.crearNotaPedido(); |
440 | 440 | ||
441 | //expect | 441 | //expect |
442 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Flete'); | 442 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Flete'); |
443 | }); | 443 | }); |
444 | 444 | ||
445 | it('funcion $scope.crearNotaPedido muestra alerta cuando domicilio es null', function() { | 445 | it('funcion $scope.crearNotaPedido muestra alerta cuando domicilio es null', function() { |
446 | 446 | ||
447 | //arrange | 447 | //arrange |
448 | var scope = {}; | 448 | var scope = {}; |
449 | var focaModalService = { | 449 | var focaModalService = { |
450 | alert: function() { } | 450 | alert: function() { } |
451 | }; | 451 | }; |
452 | 452 | ||
453 | $controler('notaPedidoCtrl', { | 453 | $controler('notaPedidoCtrl', { |
454 | $scope: scope, | 454 | $scope: scope, |
455 | $uibModal: {}, | 455 | $uibModal: {}, |
456 | $location: {}, | 456 | $location: {}, |
457 | $filter: filter, | 457 | $filter: filter, |
458 | $timeout: timeout, | 458 | $timeout: timeout, |
459 | crearNotaPedidoService: { | 459 | crearNotaPedidoService: { |
460 | getBotonera: function() { }, | 460 | getBotonera: function() { }, |
461 | getCotizacionByIdMoneda: function() { | 461 | getCotizacionByIdMoneda: function() { |
462 | return { | 462 | return { |
463 | then: function() {} | 463 | then: function() {} |
464 | }; | 464 | }; |
465 | } | 465 | } |
466 | }, | 466 | }, |
467 | focaBotoneraLateralService: {}, | 467 | focaBotoneraLateralService: {}, |
468 | focaModalService: focaModalService, | 468 | focaModalService: focaModalService, |
469 | notaPedidoBusinessService: {}, | 469 | notaPedidoBusinessService: {}, |
470 | $rootScope: { | 470 | $rootScope: { |
471 | $on: function() { } | 471 | $on: function() { } |
472 | }, | 472 | }, |
473 | focaSeguimientoService: {}, | 473 | focaSeguimientoService: {}, |
474 | APP: {}, | 474 | APP: {}, |
475 | focaLoginService: {} | 475 | focaLoginService: {} |
476 | }); | 476 | }); |
477 | 477 | ||
478 | scope.notaPedido = { | 478 | scope.notaPedido = { |
479 | vendedor: { | 479 | vendedor: { |
480 | id: true | 480 | id: true |
481 | }, | 481 | }, |
482 | cliente:{ | 482 | cliente:{ |
483 | COD: true | 483 | COD: true |
484 | }, | 484 | }, |
485 | proveedor:{ | 485 | proveedor:{ |
486 | COD: true | 486 | COD: true |
487 | }, | 487 | }, |
488 | moneda:{ | 488 | moneda:{ |
489 | ID: true | 489 | ID: true |
490 | }, | 490 | }, |
491 | cotizacion:{ | 491 | cotizacion:{ |
492 | ID: true | 492 | ID: true |
493 | }, | 493 | }, |
494 | flete: true, | 494 | flete: true, |
495 | domicilioStamp: null | 495 | domicilioStamp: null |
496 | }; | 496 | }; |
497 | 497 | ||
498 | scope.plazosPagos = true; | 498 | scope.plazosPagos = true; |
499 | 499 | ||
500 | //act | 500 | //act |
501 | spyOn(focaModalService, 'alert'); | 501 | spyOn(focaModalService, 'alert'); |
502 | scope.crearNotaPedido(); | 502 | scope.crearNotaPedido(); |
503 | 503 | ||
504 | //expect | 504 | //expect |
505 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Domicilio'); | 505 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Domicilio'); |
506 | }); | 506 | }); |
507 | 507 | ||
508 | it('funcion $scope.crearNotaPedido muestra alerta cuando no se cargaron articulos', | 508 | it('funcion $scope.crearNotaPedido muestra alerta cuando no se cargaron articulos', |
509 | function() | 509 | function() |
510 | { | 510 | { |
511 | 511 | ||
512 | //arrange | 512 | //arrange |
513 | var scope = {}; | 513 | var scope = {}; |
514 | var focaModalService = { | 514 | var focaModalService = { |
515 | alert: function() { } | 515 | alert: function() { } |
516 | }; | 516 | }; |
517 | 517 | ||
518 | $controler('notaPedidoCtrl', { | 518 | $controler('notaPedidoCtrl', { |
519 | $scope: scope, | 519 | $scope: scope, |
520 | $uibModal: {}, | 520 | $uibModal: {}, |
521 | $location: {}, | 521 | $location: {}, |
522 | $filter: filter, | 522 | $filter: filter, |
523 | $timeout: timeout, | 523 | $timeout: timeout, |
524 | crearNotaPedidoService: { | 524 | crearNotaPedidoService: { |
525 | getBotonera: function() { }, | 525 | getBotonera: function() { }, |
526 | getCotizacionByIdMoneda: function() { | 526 | getCotizacionByIdMoneda: function() { |
527 | return { | 527 | return { |
528 | then: function() {} | 528 | then: function() {} |
529 | }; | 529 | }; |
530 | } | 530 | } |
531 | }, | 531 | }, |
532 | focaBotoneraLateralService: {}, | 532 | focaBotoneraLateralService: {}, |
533 | focaModalService: focaModalService, | 533 | focaModalService: focaModalService, |
534 | notaPedidoBusinessService: {}, | 534 | notaPedidoBusinessService: {}, |
535 | $rootScope: { | 535 | $rootScope: { |
536 | $on: function() { } | 536 | $on: function() { } |
537 | }, | 537 | }, |
538 | focaSeguimientoService: {}, | 538 | focaSeguimientoService: {}, |
539 | APP: {}, | 539 | APP: {}, |
540 | focaLoginService: {} | 540 | focaLoginService: {} |
541 | }); | 541 | }); |
542 | 542 | ||
543 | scope.notaPedido = { | 543 | scope.notaPedido = { |
544 | vendedor: { | 544 | vendedor: { |
545 | id: true | 545 | id: true |
546 | }, | 546 | }, |
547 | cliente:{ | 547 | cliente:{ |
548 | COD: true | 548 | COD: true |
549 | }, | 549 | }, |
550 | proveedor:{ | 550 | proveedor:{ |
551 | COD: true | 551 | COD: true |
552 | }, | 552 | }, |
553 | moneda:{ | 553 | moneda:{ |
554 | ID: true | 554 | ID: true |
555 | }, | 555 | }, |
556 | cotizacion:{ | 556 | cotizacion:{ |
557 | ID: true | 557 | ID: true |
558 | }, | 558 | }, |
559 | flete: true, | 559 | flete: true, |
560 | domicilioStamp: true, | 560 | domicilioStamp: true, |
561 | }; | 561 | }; |
562 | 562 | ||
563 | scope.plazosPagos = true; | 563 | scope.plazosPagos = true; |
564 | scope.articulosTabla = []; | 564 | scope.articulosTabla = []; |
565 | 565 | ||
566 | //act | 566 | //act |
567 | spyOn(focaModalService, 'alert'); | 567 | spyOn(focaModalService, 'alert'); |
568 | scope.crearNotaPedido(); | 568 | scope.crearNotaPedido(); |
569 | 569 | ||
570 | //expect | 570 | //expect |
571 | expect(focaModalService.alert) | 571 | expect(focaModalService.alert) |
572 | .toHaveBeenCalledWith('Debe cargar al menos un articulo'); | 572 | .toHaveBeenCalledWith('Debe cargar al menos un articulo'); |
573 | }); | 573 | }); |
574 | 574 | ||
575 | it('funcion $scope.crearNotaPedido llama startGuardar', function() { | 575 | it('funcion $scope.crearNotaPedido llama startGuardar', function() { |
576 | 576 | ||
577 | //arrange | 577 | //arrange |
578 | var scope = {}; | 578 | var scope = {}; |
579 | var focaBotoneraLateralService = { | 579 | var focaBotoneraLateralService = { |
580 | startGuardar: function() { } | 580 | startGuardar: function() { } |
581 | }; | 581 | }; |
582 | 582 | ||
583 | $controler('notaPedidoCtrl', { | 583 | $controler('notaPedidoCtrl', { |
584 | $scope: scope, | 584 | $scope: scope, |
585 | $uibModal: {}, | 585 | $uibModal: {}, |
586 | $location: {}, | 586 | $location: {}, |
587 | $filter: filter, | 587 | $filter: filter, |
588 | $timeout: timeout, | 588 | $timeout: timeout, |
589 | crearNotaPedidoService: { | 589 | crearNotaPedidoService: { |
590 | getBotonera: function() { }, | 590 | getBotonera: function() { }, |
591 | getCotizacionByIdMoneda: function() { | 591 | getCotizacionByIdMoneda: function() { |
592 | return { | 592 | return { |
593 | then: function() {} | 593 | then: function() {} |
594 | }; | 594 | }; |
595 | }, | 595 | }, |
596 | crearNotaPedido: function() { | 596 | crearNotaPedido: function() { |
597 | return { | 597 | return { |
598 | then: function() { } | 598 | then: function() { } |
599 | }; | 599 | }; |
600 | } | 600 | } |
601 | }, | 601 | }, |
602 | focaBotoneraLateralService: focaBotoneraLateralService, | 602 | focaBotoneraLateralService: focaBotoneraLateralService, |
603 | focaModalService: {}, | 603 | focaModalService: {}, |
604 | notaPedidoBusinessService: {}, | 604 | notaPedidoBusinessService: {}, |
605 | $rootScope: { | 605 | $rootScope: { |
606 | $on: function() { } | 606 | $on: function() { } |
607 | }, | 607 | }, |
608 | focaSeguimientoService: {}, | 608 | focaSeguimientoService: {}, |
609 | APP: {}, | 609 | APP: {}, |
610 | focaLoginService: {} | 610 | focaLoginService: {} |
611 | }); | 611 | }); |
612 | 612 | ||
613 | scope.notaPedido = { | 613 | scope.notaPedido = { |
614 | vendedor: { | 614 | vendedor: { |
615 | id: true | 615 | id: true |
616 | }, | 616 | }, |
617 | cliente:{ | 617 | cliente:{ |
618 | COD: true | 618 | COD: true |
619 | }, | 619 | }, |
620 | proveedor:{ | 620 | proveedor:{ |
621 | COD: true | 621 | COD: true |
622 | }, | 622 | }, |
623 | moneda:{ | 623 | moneda:{ |
624 | ID: true | 624 | ID: true |
625 | }, | 625 | }, |
626 | cotizacion:{ | 626 | cotizacion:{ |
627 | ID: true | 627 | ID: true |
628 | }, | 628 | }, |
629 | flete: true, | 629 | flete: true, |
630 | domicilioStamp: true, | 630 | domicilioStamp: true, |
631 | domicilio: { | 631 | domicilio: { |
632 | id: true | 632 | id: true |
633 | } | 633 | } |
634 | }; | 634 | }; |
635 | 635 | ||
636 | scope.plazosPagos = true; | 636 | scope.plazosPagos = true; |
637 | scope.articulosTabla = [1]; | 637 | scope.articulosTabla = [1]; |
638 | 638 | ||
639 | //act | 639 | //act |
640 | spyOn(focaBotoneraLateralService, 'startGuardar'); | 640 | spyOn(focaBotoneraLateralService, 'startGuardar'); |
641 | scope.crearNotaPedido(); | 641 | scope.crearNotaPedido(); |
642 | 642 | ||
643 | //expect | 643 | //expect |
644 | expect(focaBotoneraLateralService.startGuardar).toHaveBeenCalled(); | 644 | expect(focaBotoneraLateralService.startGuardar).toHaveBeenCalled(); |
645 | }); | 645 | }); |
646 | 646 | ||
647 | it('funcion $scope.crearNotaPedido llama funciones al guardar', function(done) { | 647 | it('funcion $scope.crearNotaPedido llama funciones al guardar', function(done) { |
648 | 648 | ||
649 | //arrange | 649 | //arrange |
650 | var scope = {}; | 650 | var scope = {}; |
651 | var focaBotoneraLateralService = { | 651 | var focaBotoneraLateralService = { |
652 | startGuardar: function() { }, | 652 | startGuardar: function() { }, |
653 | endGuardar: function() { } | 653 | endGuardar: function() { } |
654 | }; | 654 | }; |
655 | var focaSeguimientoService = { | 655 | var focaSeguimientoService = { |
656 | guardarPosicion: function() { } | 656 | guardarPosicion: function() { } |
657 | }; | 657 | }; |
658 | var notaPedidoBusinessService = { | 658 | var notaPedidoBusinessService = { |
659 | addArticulos: function() { }, | 659 | addArticulos: function() { }, |
660 | addEstado: function() { } | 660 | addEstado: function() { } |
661 | }; | 661 | }; |
662 | var crearNotaPedidoService = { | 662 | var crearNotaPedidoService = { |
663 | getBotonera: function() { }, | 663 | getBotonera: function() { }, |
664 | getCotizacionByIdMoneda: function() { | 664 | getCotizacionByIdMoneda: function() { |
665 | return { | 665 | return { |
666 | then: function() {} | 666 | then: function() {} |
667 | }; | 667 | }; |
668 | }, | 668 | }, |
669 | crearNotaPedido: function() { }, | 669 | crearNotaPedido: function() { }, |
670 | getNumeroNotaPedido: function() { | 670 | getNumeroNotaPedido: function() { |
671 | return { | 671 | return { |
672 | then: function() { } | 672 | then: function() { } |
673 | }; | 673 | }; |
674 | } | 674 | } |
675 | }; | 675 | }; |
676 | 676 | ||
677 | $controler('notaPedidoCtrl', { | 677 | $controler('notaPedidoCtrl', { |
678 | $scope: scope, | 678 | $scope: scope, |
679 | $uibModal: {}, | 679 | $uibModal: {}, |
680 | $location: {}, | 680 | $location: {}, |
681 | $filter: filter, | 681 | $filter: filter, |
682 | $timeout: timeout, | 682 | $timeout: timeout, |
683 | crearNotaPedidoService: crearNotaPedidoService, | 683 | crearNotaPedidoService: crearNotaPedidoService, |
684 | focaBotoneraLateralService: focaBotoneraLateralService, | 684 | focaBotoneraLateralService: focaBotoneraLateralService, |
685 | focaModalService: {}, | 685 | focaModalService: {}, |
686 | notaPedidoBusinessService: notaPedidoBusinessService, | 686 | notaPedidoBusinessService: notaPedidoBusinessService, |
687 | $rootScope: { | 687 | $rootScope: { |
688 | $on: function() { } | 688 | $on: function() { } |
689 | }, | 689 | }, |
690 | focaSeguimientoService: focaSeguimientoService, | 690 | focaSeguimientoService: focaSeguimientoService, |
691 | APP: {}, | 691 | APP: {}, |
692 | focaLoginService: {} | 692 | focaLoginService: {} |
693 | }); | 693 | }); |
694 | 694 | ||
695 | scope.notaPedido = { | 695 | scope.notaPedido = { |
696 | vendedor: { | 696 | vendedor: { |
697 | id: true | 697 | id: true |
698 | }, | 698 | }, |
699 | cliente:{ | 699 | cliente:{ |
700 | COD: true | 700 | COD: true |
701 | }, | 701 | }, |
702 | proveedor:{ | 702 | proveedor:{ |
703 | COD: true | 703 | COD: true |
704 | }, | 704 | }, |
705 | moneda:{ | 705 | moneda:{ |
706 | ID: true | 706 | ID: true |
707 | }, | 707 | }, |
708 | cotizacion:{ | 708 | cotizacion:{ |
709 | ID: true | 709 | ID: true |
710 | }, | 710 | }, |
711 | flete: true, | 711 | flete: true, |
712 | domicilioStamp: true, | 712 | domicilioStamp: true, |
713 | domicilio: { | 713 | domicilio: { |
714 | id: true | 714 | id: true |
715 | } | 715 | } |
716 | }; | 716 | }; |
717 | 717 | ||
718 | scope.plazosPagos = []; | 718 | scope.plazosPagos = []; |
719 | scope.articulosTabla = [1]; | 719 | scope.articulosTabla = [1]; |
720 | 720 | ||
721 | var promesa = Promise.resolve({ data: 1 }); | 721 | var promesa = Promise.resolve({ data: 1 }); |
722 | scope.$broadcast = function() { }; | 722 | scope.$broadcast = function() { }; |
723 | 723 | ||
724 | //act | 724 | //act |
725 | spyOn(crearNotaPedidoService, 'crearNotaPedido').and.returnValue(promesa); | 725 | spyOn(crearNotaPedidoService, 'crearNotaPedido').and.returnValue(promesa); |
726 | spyOn(focaSeguimientoService, 'guardarPosicion'); | 726 | spyOn(focaSeguimientoService, 'guardarPosicion'); |
727 | spyOn(notaPedidoBusinessService, 'addArticulos'); | 727 | spyOn(notaPedidoBusinessService, 'addArticulos'); |
728 | scope.crearNotaPedido(); | 728 | scope.crearNotaPedido(); |
729 | 729 | ||
730 | //expect | 730 | //expect |
731 | promesa.then(function() { | 731 | promesa.then(function() { |
732 | expect(focaSeguimientoService.guardarPosicion).toHaveBeenCalled(); | 732 | expect(focaSeguimientoService.guardarPosicion).toHaveBeenCalled(); |
733 | expect(notaPedidoBusinessService.addArticulos).toHaveBeenCalled(); | 733 | expect(notaPedidoBusinessService.addArticulos).toHaveBeenCalled(); |
734 | done(); | 734 | done(); |
735 | }); | 735 | }); |
736 | }); | 736 | }); |
737 | }); | 737 | }); |
738 | }); | ||
738 | }); |