Commit a7e2d288f8ae8e32fdaa91f2470a93006bda61eb
1 parent
5c70357d77
Exists in
master
Arreglo de espacios
Showing
1 changed file
with
3 additions
and
5 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 | MOD: undefined | 914 | MOD: undefined |
915 | }; | 915 | }; |
916 | 916 | ||
917 | //act | 917 | //act |
918 | spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); | 918 | spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); |
919 | spyOn(scope, '$broadcast'); | 919 | spyOn(scope, '$broadcast'); |
920 | scope.abrirModalDomicilios(cliente); | 920 | scope.abrirModalDomicilios(cliente); |
921 | 921 | ||
922 | //assert | 922 | //assert |
923 | promesaRespuesta.result.then(function() { | 923 | promesaRespuesta.result.then(function() { |
924 | //scope.notaPedido.domicilio sea vacio | 924 | //scope.notaPedido.domicilio sea vacio |
925 | expect(scope.notaPedido.domicilio).toEqual(respuesta); | 925 | expect(scope.notaPedido.domicilio).toEqual(respuesta); |
926 | expect(scope.notaPedido.cliente).toEqual(cliente); | 926 | expect(scope.notaPedido.cliente).toEqual(cliente); |
927 | expect(scope.$broadcast).toHaveBeenCalled(); | 927 | expect(scope.$broadcast).toHaveBeenCalled(); |
928 | done(); | 928 | done(); |
929 | }); | 929 | }); |
930 | }); | 930 | }); |
931 | 931 | ||
932 | it('función getTotal devulve correctamente', function() { | 932 | it('función getTotal devulve correctamente', function() { |
933 | 933 | ||
934 | //arrange | 934 | //arrange |
935 | var scope = { | 935 | var scope = { |
936 | $watch: function() { }, | 936 | $watch: function() { }, |
937 | $broadcast: function() { } | 937 | $broadcast: function() { } |
938 | }; | 938 | }; |
939 | 939 | ||
940 | $controler('notaPedidoCtrl', { | 940 | $controler('notaPedidoCtrl', { |
941 | $scope: scope, | 941 | $scope: scope, |
942 | $uibModal: {}, | 942 | $uibModal: {}, |
943 | $location: {}, | 943 | $location: {}, |
944 | $filter: filter, | 944 | $filter: filter, |
945 | $timeout: timeout, | 945 | $timeout: timeout, |
946 | crearNotaPedidoService: { | 946 | crearNotaPedidoService: { |
947 | getNumeroNotaPedido: function() { | 947 | getNumeroNotaPedido: function() { |
948 | return { | 948 | return { |
949 | then: function() { } | 949 | then: function() { } |
950 | }; | 950 | }; |
951 | }, | 951 | }, |
952 | getBotonera: function() { }, | 952 | getBotonera: function() { }, |
953 | getCotizacionByIdMoneda: function() { | 953 | getCotizacionByIdMoneda: function() { |
954 | return { | 954 | return { |
955 | then: function() { } | 955 | then: function() { } |
956 | }; | 956 | }; |
957 | } | 957 | } |
958 | }, | 958 | }, |
959 | focaBotoneraLateralService: {}, | 959 | focaBotoneraLateralService: {}, |
960 | focaModalService: {}, | 960 | focaModalService: {}, |
961 | notaPedidoBusinessService: {}, | 961 | notaPedidoBusinessService: {}, |
962 | $rootScope: { | 962 | $rootScope: { |
963 | $on: function() { } | 963 | $on: function() { } |
964 | }, | 964 | }, |
965 | focaSeguimientoService: {}, | 965 | focaSeguimientoService: {}, |
966 | APP: {}, | 966 | APP: {}, |
967 | focaLoginService: {}, | 967 | focaLoginService: {}, |
968 | $localStorage: {} | 968 | $localStorage: {} |
969 | }); | 969 | }); |
970 | scope.idLista = true; | 970 | scope.idLista = true; |
971 | scope.notaPedido = { | 971 | scope.notaPedido = { |
972 | vendedor: { NUM: true } | 972 | vendedor: { NUM: true } |
973 | }; | 973 | }; |
974 | 974 | ||
975 | //act | 975 | //act |
976 | scope.notaPedido.articulosNotaPedido = [{ precio: 2, cantidad: 1}]; | 976 | scope.notaPedido.articulosNotaPedido = [{ precio: 2, cantidad: 1}]; |
977 | var esperado = 2; | 977 | var esperado = 2; |
978 | var resultado = scope.getTotal(); | 978 | var resultado = scope.getTotal(); |
979 | 979 | ||
980 | //assert | 980 | //assert |
981 | expect(resultado).toEqual(esperado); | 981 | expect(resultado).toEqual(esperado); |
982 | }); | 982 | }); |
983 | 983 | ||
984 | it('función getSubTotal devulve correctamente', function() { | 984 | it('función getSubTotal devulve correctamente', function() { |
985 | 985 | ||
986 | //arrange | 986 | //arrange |
987 | var scope = { | 987 | var scope = { |
988 | $watch: function() { }, | 988 | $watch: function() { }, |
989 | $broadcast: function() { } | 989 | $broadcast: function() { } |
990 | }; | 990 | }; |
991 | 991 | ||
992 | $controler('notaPedidoCtrl', { | 992 | $controler('notaPedidoCtrl', { |
993 | $scope: scope, | 993 | $scope: scope, |
994 | $uibModal: {}, | 994 | $uibModal: {}, |
995 | $location: {}, | 995 | $location: {}, |
996 | $filter: filter, | 996 | $filter: filter, |
997 | $timeout: timeout, | 997 | $timeout: timeout, |
998 | crearNotaPedidoService: { | 998 | crearNotaPedidoService: { |
999 | getNumeroNotaPedido: function() { | 999 | getNumeroNotaPedido: function() { |
1000 | return { | 1000 | return { |
1001 | then: function() { } | 1001 | then: function() { } |
1002 | }; | 1002 | }; |
1003 | }, | 1003 | }, |
1004 | getBotonera: function() { }, | 1004 | getBotonera: function() { }, |
1005 | getCotizacionByIdMoneda: function() { | 1005 | getCotizacionByIdMoneda: function() { |
1006 | return { | 1006 | return { |
1007 | then: function() { } | 1007 | then: function() { } |
1008 | }; | 1008 | }; |
1009 | } | 1009 | } |
1010 | }, | 1010 | }, |
1011 | focaBotoneraLateralService: {}, | 1011 | focaBotoneraLateralService: {}, |
1012 | focaModalService: {}, | 1012 | focaModalService: {}, |
1013 | notaPedidoBusinessService: {}, | 1013 | notaPedidoBusinessService: {}, |
1014 | $rootScope: { | 1014 | $rootScope: { |
1015 | $on: function() { } | 1015 | $on: function() { } |
1016 | }, | 1016 | }, |
1017 | focaSeguimientoService: {}, | 1017 | focaSeguimientoService: {}, |
1018 | APP: {}, | 1018 | APP: {}, |
1019 | focaLoginService: {}, | 1019 | focaLoginService: {}, |
1020 | $localStorage: {} | 1020 | $localStorage: {} |
1021 | }); | 1021 | }); |
1022 | scope.idLista = true; | 1022 | scope.idLista = true; |
1023 | scope.notaPedido = { | 1023 | scope.notaPedido = { |
1024 | vendedor: { NUM: true } | 1024 | vendedor: { NUM: true } |
1025 | }; | 1025 | }; |
1026 | 1026 | ||
1027 | //act | 1027 | //act |
1028 | scope.articuloACargar = { precio: 2, cantidad: 1}; | 1028 | scope.articuloACargar = { precio: 2, cantidad: 1}; |
1029 | var esperado = 2; | 1029 | var esperado = 2; |
1030 | var resultado = scope.getSubTotal(); | 1030 | var resultado = scope.getSubTotal(); |
1031 | 1031 | ||
1032 | //assert | 1032 | //assert |
1033 | expect(resultado).toEqual(esperado); | 1033 | expect(resultado).toEqual(esperado); |
1034 | }); | 1034 | }); |
1035 | 1035 | ||
1036 | it('función seleccionarPreciosYCondiciones abre modal', function() { | 1036 | it('función seleccionarPreciosYCondiciones abre modal', function() { |
1037 | 1037 | ||
1038 | //arrange | 1038 | //arrange |
1039 | var scope = { | 1039 | var scope = { |
1040 | $watch: function() { }, | 1040 | $watch: function() { }, |
1041 | $broadcast: function() { } | 1041 | $broadcast: function() { } |
1042 | |||
1043 | |||
1044 | }; | 1042 | }; |
1045 | var uibModal = { | 1043 | var uibModal = { |
1046 | open: function() { } | 1044 | open: function() { } |
1047 | }; | 1045 | }; |
1048 | 1046 | ||
1049 | $controler('notaPedidoCtrl', { | 1047 | $controler('notaPedidoCtrl', { |
1050 | $scope: scope, | 1048 | $scope: scope, |
1051 | $uibModal: uibModal, | 1049 | $uibModal: uibModal, |
1052 | $location: {}, | 1050 | $location: {}, |
1053 | $filter: filter, | 1051 | $filter: filter, |
1054 | $timeout: timeout, | 1052 | $timeout: timeout, |
1055 | crearNotaPedidoService: { | 1053 | crearNotaPedidoService: { |
1056 | getNumeroNotaPedido: function() { | 1054 | getNumeroNotaPedido: function() { |
1057 | return { | 1055 | return { |
1058 | then: function() { } | 1056 | then: function() { } |
1059 | }; | 1057 | }; |
1060 | }, | 1058 | }, |
1061 | getBotonera: function() { }, | 1059 | getBotonera: function() { }, |
1062 | getCotizacionByIdMoneda: function() { | 1060 | getCotizacionByIdMoneda: function() { |
1063 | return { | 1061 | return { |
1064 | then: function() { } | 1062 | then: function() { } |
1065 | }; | 1063 | }; |
1066 | } | 1064 | } |
1067 | }, | 1065 | }, |
1068 | focaBotoneraLateralService: {}, | 1066 | focaBotoneraLateralService: {}, |
1069 | focaModalService: {}, | 1067 | focaModalService: {}, |
1070 | notaPedidoBusinessService: {}, | 1068 | notaPedidoBusinessService: {}, |
1071 | $rootScope: { | 1069 | $rootScope: { |
1072 | $on: function() { } | 1070 | $on: function() { } |
1073 | }, | 1071 | }, |
1074 | focaSeguimientoService: {}, | 1072 | focaSeguimientoService: {}, |
1075 | APP: {}, | 1073 | APP: {}, |
1076 | focaLoginService: {}, | 1074 | focaLoginService: {}, |
1077 | $localStorage: {} | 1075 | $localStorage: {} |
1078 | }); | 1076 | }); |
1079 | 1077 | ||
1080 | scope.notaPedido = { | 1078 | scope.notaPedido = { |
1081 | cliente: { COD: true } | 1079 | cliente: { COD: true } |
1082 | }; | 1080 | }; |
1083 | 1081 | ||
1084 | var respuesta = { result: {then: function() { } } }; | 1082 | var respuesta = { result: {then: function() { } } }; |
1085 | 1083 | ||
1086 | //act | 1084 | //act |
1087 | spyOn(uibModal, 'open').and.returnValue(respuesta); | 1085 | spyOn(uibModal, 'open').and.returnValue(respuesta); |
1088 | scope.seleccionarPreciosYCondiciones(); | 1086 | scope.seleccionarPreciosYCondiciones(); |
1089 | 1087 | ||
1090 | //assert | 1088 | //assert |
1091 | expect(uibModal.open).toHaveBeenCalled(); | 1089 | expect(uibModal.open).toHaveBeenCalled(); |
1092 | }); | 1090 | }); |
1093 | 1091 | ||
1094 | it('función seleccionarPreciosYCondiciones setea articulos y cabecera', function(done) { | 1092 | it('función seleccionarPreciosYCondiciones setea articulos y cabecera', function(done) { |
1095 | 1093 | ||
1096 | //arrange | 1094 | //arrange |
1097 | var scope = { | 1095 | var scope = { |
1098 | $watch: function() { }, | 1096 | $watch: function() { }, |
1099 | $broadcast: function() { } | 1097 | $broadcast: function() { } |
1100 | }; | 1098 | }; |
1101 | var uibModal = { | 1099 | var uibModal = { |
1102 | open: function() { } | 1100 | open: function() { } |
1103 | }; | 1101 | }; |
1104 | 1102 | ||
1105 | $controler('notaPedidoCtrl', { | 1103 | $controler('notaPedidoCtrl', { |
1106 | $scope: scope, | 1104 | $scope: scope, |
1107 | $uibModal: uibModal, | 1105 | $uibModal: uibModal, |
1108 | $location: {}, | 1106 | $location: {}, |
1109 | $filter: filter, | 1107 | $filter: filter, |
1110 | $timeout: timeout, | 1108 | $timeout: timeout, |
1111 | crearNotaPedidoService: { | 1109 | crearNotaPedidoService: { |
1112 | getNumeroNotaPedido: function() { | 1110 | getNumeroNotaPedido: function() { |
1113 | return { | 1111 | return { |
1114 | then: function() { } | 1112 | then: function() { } |
1115 | }; | 1113 | }; |
1116 | }, | 1114 | }, |
1117 | getBotonera: function() { }, | 1115 | getBotonera: function() { }, |
1118 | getCotizacionByIdMoneda: function() { | 1116 | getCotizacionByIdMoneda: function() { |
1119 | return { | 1117 | return { |
1120 | then: function() { } | 1118 | then: function() { } |
1121 | }; | 1119 | }; |
1122 | } | 1120 | } |
1123 | }, | 1121 | }, |
1124 | focaBotoneraLateralService: {}, | 1122 | focaBotoneraLateralService: {}, |
1125 | focaModalService: {}, | 1123 | focaModalService: {}, |
1126 | notaPedidoBusinessService: {}, | 1124 | notaPedidoBusinessService: {}, |
1127 | $rootScope: { | 1125 | $rootScope: { |
1128 | $on: function() { } | 1126 | $on: function() { } |
1129 | }, | 1127 | }, |
1130 | focaSeguimientoService: {}, | 1128 | focaSeguimientoService: {}, |
1131 | APP: {}, | 1129 | APP: {}, |
1132 | focaLoginService: {}, | 1130 | focaLoginService: {}, |
1133 | $localStorage: {} | 1131 | $localStorage: {} |
1134 | }); | 1132 | }); |
1135 | scope.idLista = true; | 1133 | scope.idLista = true; |
1136 | scope.notaPedido = { | 1134 | scope.notaPedido = { |
1137 | vendedor: { NUM: true }, | 1135 | vendedor: { NUM: true }, |
1138 | cliente: { COD: true } | 1136 | cliente: { COD: true } |
1139 | }; | 1137 | }; |
1140 | var respuesta = { plazoPago: { } }; | 1138 | var respuesta = { plazoPago: { } }; |
1141 | var promesaRespuesta = { result: Promise.resolve(respuesta) }; | 1139 | var promesaRespuesta = { result: Promise.resolve(respuesta) }; |
1142 | scope.$broadcast = function() { }; | 1140 | scope.$broadcast = function() { }; |
1143 | 1141 | ||
1144 | //act | 1142 | //act |
1145 | spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); | 1143 | spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); |
1146 | spyOn(scope, '$broadcast'); | 1144 | spyOn(scope, '$broadcast'); |
1147 | scope.seleccionarPreciosYCondiciones(); | 1145 | scope.seleccionarPreciosYCondiciones(); |
1148 | 1146 | ||
1149 | //assert | 1147 | //assert |
1150 | promesaRespuesta.result.then(function() { | 1148 | promesaRespuesta.result.then(function() { |
1151 | expect(scope.notaPedido.articulosNotaPedido.length).toEqual(0); | 1149 | expect(scope.notaPedido.articulosNotaPedido.length).toEqual(0); |
1152 | expect(scope.$broadcast).toHaveBeenCalled(); | 1150 | expect(scope.$broadcast).toHaveBeenCalled(); |
1153 | done(); | 1151 | done(); |
1154 | }); | 1152 | }); |
1155 | }); | 1153 | }); |
1156 | 1154 | ||
1157 | it('función seleccionarMoneda abre modal', function() { | 1155 | it('función seleccionarMoneda abre modal', function() { |
1158 | //arrange | 1156 | //arrange |
1159 | var scope = { | 1157 | var scope = { |
1160 | $watch: function() { }, | 1158 | $watch: function() { }, |
1161 | $broadcast: function() { } | 1159 | $broadcast: function() { } |
1162 | }; | 1160 | }; |
1163 | var focaModalService = { | 1161 | var focaModalService = { |
1164 | modal: function() { } | 1162 | modal: function() { } |
1165 | }; | 1163 | }; |
1166 | 1164 | ||
1167 | $controler('notaPedidoCtrl', { | 1165 | $controler('notaPedidoCtrl', { |
1168 | $scope: scope, | 1166 | $scope: scope, |
1169 | $uibModal: {}, | 1167 | $uibModal: {}, |
1170 | $location: {}, | 1168 | $location: {}, |
1171 | $filter: filter, | 1169 | $filter: filter, |
1172 | $timeout: timeout, | 1170 | $timeout: timeout, |
1173 | crearNotaPedidoService: { | 1171 | crearNotaPedidoService: { |
1174 | getNumeroNotaPedido: function() { | 1172 | getNumeroNotaPedido: function() { |
1175 | return { | 1173 | return { |
1176 | then: function() { } | 1174 | then: function() { } |
1177 | }; | 1175 | }; |
1178 | }, | 1176 | }, |
1179 | getBotonera: function() { }, | 1177 | getBotonera: function() { }, |
1180 | getCotizacionByIdMoneda: function() { | 1178 | getCotizacionByIdMoneda: function() { |
1181 | return { | 1179 | return { |
1182 | then: function() { } | 1180 | then: function() { } |
1183 | }; | 1181 | }; |
1184 | } | 1182 | } |
1185 | }, | 1183 | }, |
1186 | focaBotoneraLateralService: {}, | 1184 | focaBotoneraLateralService: {}, |
1187 | focaModalService: focaModalService, | 1185 | focaModalService: focaModalService, |
1188 | notaPedidoBusinessService: {}, | 1186 | notaPedidoBusinessService: {}, |
1189 | $rootScope: { | 1187 | $rootScope: { |
1190 | $on: function() { } | 1188 | $on: function() { } |
1191 | }, | 1189 | }, |
1192 | focaSeguimientoService: {}, | 1190 | focaSeguimientoService: {}, |
1193 | APP: {}, | 1191 | APP: {}, |
1194 | focaLoginService: {}, | 1192 | focaLoginService: {}, |
1195 | $localStorage: {} | 1193 | $localStorage: {} |
1196 | }); | 1194 | }); |
1197 | scope.notaPedido = {}; | 1195 | scope.notaPedido = {}; |
1198 | 1196 | ||
1199 | var respuesta = { then: function() { } }; | 1197 | var respuesta = { then: function() { } }; |
1200 | 1198 | ||
1201 | //act | 1199 | //act |
1202 | spyOn(focaModalService, 'modal').and.returnValue(respuesta); | 1200 | spyOn(focaModalService, 'modal').and.returnValue(respuesta); |
1203 | scope.seleccionarMoneda(); | 1201 | scope.seleccionarMoneda(); |
1204 | 1202 | ||
1205 | //assert | 1203 | //assert |
1206 | expect(focaModalService.modal).toHaveBeenCalled(); | 1204 | expect(focaModalService.modal).toHaveBeenCalled(); |
1207 | }); | 1205 | }); |
1208 | 1206 | ||
1209 | it('función seleccionarMoneda llama Modal Cotizacion', function(done) { | 1207 | it('función seleccionarMoneda llama Modal Cotizacion', function(done) { |
1210 | //arrange | 1208 | //arrange |
1211 | var scope = { | 1209 | var scope = { |
1212 | $watch: function() { }, | 1210 | $watch: function() { }, |
1213 | $broadcast: function() { } | 1211 | $broadcast: function() { } |
1214 | }; | 1212 | }; |
1215 | var focaModalService = { | 1213 | var focaModalService = { |
1216 | modal: function() { } | 1214 | modal: function() { } |
1217 | }; | 1215 | }; |
1218 | 1216 | ||
1219 | $controler('notaPedidoCtrl', { | 1217 | $controler('notaPedidoCtrl', { |
1220 | $scope: scope, | 1218 | $scope: scope, |
1221 | $uibModal: {}, | 1219 | $uibModal: {}, |
1222 | $location: {}, | 1220 | $location: {}, |
1223 | $filter: filter, | 1221 | $filter: filter, |
1224 | $timeout: timeout, | 1222 | $timeout: timeout, |
1225 | crearNotaPedidoService: { | 1223 | crearNotaPedidoService: { |
1226 | getNumeroNotaPedido: function() { | 1224 | getNumeroNotaPedido: function() { |
1227 | return { | 1225 | return { |
1228 | then: function() { } | 1226 | then: function() { } |
1229 | }; | 1227 | }; |
1230 | }, | 1228 | }, |
1231 | getBotonera: function() { }, | 1229 | getBotonera: function() { }, |
1232 | getCotizacionByIdMoneda: function() { | 1230 | getCotizacionByIdMoneda: function() { |
1233 | return { | 1231 | return { |
1234 | then: function() { } | 1232 | then: function() { } |
1235 | }; | 1233 | }; |
1236 | } | 1234 | } |
1237 | }, | 1235 | }, |
1238 | focaBotoneraLateralService: {}, | 1236 | focaBotoneraLateralService: {}, |
1239 | focaModalService: focaModalService, | 1237 | focaModalService: focaModalService, |
1240 | notaPedidoBusinessService: {}, | 1238 | notaPedidoBusinessService: {}, |
1241 | $rootScope: { | 1239 | $rootScope: { |
1242 | $on: function() { } | 1240 | $on: function() { } |
1243 | }, | 1241 | }, |
1244 | focaSeguimientoService: {}, | 1242 | focaSeguimientoService: {}, |
1245 | APP: {}, | 1243 | APP: {}, |
1246 | focaLoginService: {}, | 1244 | focaLoginService: {}, |
1247 | $localStorage: {} | 1245 | $localStorage: {} |
1248 | }); | 1246 | }); |
1249 | 1247 | ||
1250 | scope.notaPedido = {}; | 1248 | scope.notaPedido = {}; |
1251 | var respuesta = 'test'; | 1249 | var respuesta = 'test'; |
1252 | var promesaRespuesta = Promise.resolve(respuesta); | 1250 | var promesaRespuesta = Promise.resolve(respuesta); |
1253 | 1251 | ||
1254 | //act | 1252 | //act |
1255 | spyOn(focaModalService, 'modal').and.returnValue(promesaRespuesta); | 1253 | spyOn(focaModalService, 'modal').and.returnValue(promesaRespuesta); |
1256 | spyOn(scope, 'abrirModalCotizacion'); | 1254 | spyOn(scope, 'abrirModalCotizacion'); |
1257 | scope.seleccionarMoneda(); | 1255 | scope.seleccionarMoneda(); |
1258 | 1256 | ||
1259 | //assert | 1257 | //assert |
1260 | promesaRespuesta.then(function() { | 1258 | promesaRespuesta.then(function() { |
1261 | expect(scope.abrirModalCotizacion).toHaveBeenCalledWith('test'); | 1259 | expect(scope.abrirModalCotizacion).toHaveBeenCalledWith('test'); |
1262 | done(); | 1260 | done(); |
1263 | }); | 1261 | }); |
1264 | }); | 1262 | }); |
1265 | 1263 | ||
1266 | it('función seleccionarObservaciones llama a prompt', function() { | 1264 | it('función seleccionarObservaciones llama a prompt', function() { |
1267 | 1265 | ||
1268 | //arrange | 1266 | //arrange |
1269 | var scope = { | 1267 | var scope = { |
1270 | $watch: function() { }, | 1268 | $watch: function() { }, |
1271 | $broadcast: function() { } | 1269 | $broadcast: function() { } |
1272 | }; | 1270 | }; |
1273 | var focaModalService = { | 1271 | var focaModalService = { |
1274 | prompt: function() { } | 1272 | prompt: function() { } |
1275 | }; | 1273 | }; |
1276 | 1274 | ||
1277 | $controler('notaPedidoCtrl', { | 1275 | $controler('notaPedidoCtrl', { |
1278 | $scope: scope, | 1276 | $scope: scope, |
1279 | $uibModal: {}, | 1277 | $uibModal: {}, |
1280 | $location: {}, | 1278 | $location: {}, |
1281 | $filter: filter, | 1279 | $filter: filter, |
1282 | $timeout: timeout, | 1280 | $timeout: timeout, |
1283 | crearNotaPedidoService: { | 1281 | crearNotaPedidoService: { |
1284 | getNumeroNotaPedido: function() { | 1282 | getNumeroNotaPedido: function() { |
1285 | return { | 1283 | return { |
1286 | then: function() { } | 1284 | then: function() { } |
1287 | }; | 1285 | }; |
1288 | }, | 1286 | }, |
1289 | getBotonera: function() { }, | 1287 | getBotonera: function() { }, |
1290 | getCotizacionByIdMoneda: function() { | 1288 | getCotizacionByIdMoneda: function() { |
1291 | return { | 1289 | return { |
1292 | then: function() { } | 1290 | then: function() { } |
1293 | }; | 1291 | }; |
1294 | } | 1292 | } |
1295 | }, | 1293 | }, |
1296 | focaBotoneraLateralService: {}, | 1294 | focaBotoneraLateralService: {}, |
1297 | focaModalService: focaModalService, | 1295 | focaModalService: focaModalService, |
1298 | notaPedidoBusinessService: {}, | 1296 | notaPedidoBusinessService: {}, |
1299 | $rootScope: { | 1297 | $rootScope: { |
1300 | $on: function() { } | 1298 | $on: function() { } |
1301 | }, | 1299 | }, |
1302 | focaSeguimientoService: {}, | 1300 | focaSeguimientoService: {}, |
1303 | APP: {}, | 1301 | APP: {}, |
1304 | focaLoginService: {}, | 1302 | focaLoginService: {}, |
1305 | $localStorage: {} | 1303 | $localStorage: {} |
1306 | }); | 1304 | }); |
1307 | var respuesta = { then: function() { } }; | 1305 | var respuesta = { then: function() { } }; |
1308 | scope.notaPedido = {}; | 1306 | scope.notaPedido = {}; |
1309 | 1307 | ||
1310 | //act | 1308 | //act |
1311 | spyOn(focaModalService, 'prompt').and.returnValue(respuesta); | 1309 | spyOn(focaModalService, 'prompt').and.returnValue(respuesta); |
1312 | scope.seleccionarObservaciones(); | 1310 | scope.seleccionarObservaciones(); |
1313 | 1311 | ||
1314 | //assert | 1312 | //assert |
1315 | expect(focaModalService.prompt).toHaveBeenCalled(); | 1313 | expect(focaModalService.prompt).toHaveBeenCalled(); |
1316 | }); | 1314 | }); |
1317 | 1315 | ||
1318 | it('función seleccionarObservaciones setea observaciones', function(done) { | 1316 | it('función seleccionarObservaciones setea observaciones', function(done) { |
1319 | 1317 | ||
1320 | //arrange | 1318 | //arrange |
1321 | var scope = { | 1319 | var scope = { |
1322 | $watch: function() { }, | 1320 | $watch: function() { }, |
1323 | $broadcast: function() { } | 1321 | $broadcast: function() { } |
1324 | }; | 1322 | }; |
1325 | var focaModalService = { | 1323 | var focaModalService = { |
1326 | prompt: function() { } | 1324 | prompt: function() { } |
1327 | }; | 1325 | }; |
1328 | 1326 | ||
1329 | $controler('notaPedidoCtrl', { | 1327 | $controler('notaPedidoCtrl', { |
1330 | $scope: scope, | 1328 | $scope: scope, |
1331 | $uibModal: {}, | 1329 | $uibModal: {}, |
1332 | $location: {}, | 1330 | $location: {}, |
1333 | $filter: filter, | 1331 | $filter: filter, |
1334 | $timeout: timeout, | 1332 | $timeout: timeout, |
1335 | crearNotaPedidoService: { | 1333 | crearNotaPedidoService: { |
1336 | getNumeroNotaPedido: function() { | 1334 | getNumeroNotaPedido: function() { |
1337 | return { | 1335 | return { |
1338 | then: function() { } | 1336 | then: function() { } |
1339 | }; | 1337 | }; |
1340 | }, | 1338 | }, |
1341 | getBotonera: function() { }, | 1339 | getBotonera: function() { }, |
1342 | getCotizacionByIdMoneda: function() { | 1340 | getCotizacionByIdMoneda: function() { |
1343 | return { | 1341 | return { |
1344 | then: function() { } | 1342 | then: function() { } |
1345 | }; | 1343 | }; |
1346 | } | 1344 | } |
1347 | }, | 1345 | }, |
1348 | focaBotoneraLateralService: {}, | 1346 | focaBotoneraLateralService: {}, |
1349 | focaModalService: focaModalService, | 1347 | focaModalService: focaModalService, |
1350 | notaPedidoBusinessService: {}, | 1348 | notaPedidoBusinessService: {}, |
1351 | $rootScope: { | 1349 | $rootScope: { |
1352 | $on: function() { } | 1350 | $on: function() { } |
1353 | }, | 1351 | }, |
1354 | focaSeguimientoService: {}, | 1352 | focaSeguimientoService: {}, |
1355 | APP: {}, | 1353 | APP: {}, |
1356 | focaLoginService: {}, | 1354 | focaLoginService: {}, |
1357 | $localStorage: {} | 1355 | $localStorage: {} |
1358 | }); | 1356 | }); |
1359 | var respuesta = 'unit test'; | 1357 | var respuesta = 'unit test'; |
1360 | var promesa = Promise.resolve(respuesta); | 1358 | var promesa = Promise.resolve(respuesta); |
1361 | scope.notaPedido = {}; | 1359 | scope.notaPedido = {}; |
1362 | 1360 | ||
1363 | //act | 1361 | //act |
1364 | spyOn(focaModalService, 'prompt').and.returnValue(promesa); | 1362 | spyOn(focaModalService, 'prompt').and.returnValue(promesa); |
1365 | scope.seleccionarObservaciones(); | 1363 | scope.seleccionarObservaciones(); |
1366 | 1364 | ||
1367 | //assert | 1365 | //assert |
1368 | promesa.then(function() { | 1366 | promesa.then(function() { |
1369 | expect(scope.notaPedido.observaciones).toEqual(respuesta); | 1367 | expect(scope.notaPedido.observaciones).toEqual(respuesta); |
1370 | done(); | 1368 | done(); |
1371 | }); | 1369 | }); |
1372 | }); | 1370 | }); |
1373 | 1371 | ||
1374 | it('función abrirModalCotizacion abre modal', function() { | 1372 | it('función abrirModalCotizacion abre modal', function() { |
1375 | 1373 | ||
1376 | //arrange | 1374 | //arrange |
1377 | var scope = { | 1375 | var scope = { |
1378 | $watch: function() { }, | 1376 | $watch: function() { }, |
1379 | $broadcast: function() { } | 1377 | $broadcast: function() { } |
1380 | }; | 1378 | }; |
1381 | var uibModal = { | 1379 | var uibModal = { |
1382 | open: function() { } | 1380 | open: function() { } |
1383 | }; | 1381 | }; |
1384 | 1382 | ||
1385 | $controler('notaPedidoCtrl', { | 1383 | $controler('notaPedidoCtrl', { |
1386 | $scope: scope, | 1384 | $scope: scope, |
1387 | $uibModal: uibModal, | 1385 | $uibModal: uibModal, |
1388 | $location: {}, | 1386 | $location: {}, |
1389 | $filter: filter, | 1387 | $filter: filter, |
1390 | $timeout: timeout, | 1388 | $timeout: timeout, |
1391 | crearNotaPedidoService: { | 1389 | crearNotaPedidoService: { |
1392 | getNumeroNotaPedido: function() { | 1390 | getNumeroNotaPedido: function() { |
1393 | return { | 1391 | return { |
1394 | then: function() { } | 1392 | then: function() { } |
1395 | }; | 1393 | }; |
1396 | }, | 1394 | }, |
1397 | getBotonera: function() { }, | 1395 | getBotonera: function() { }, |
1398 | getCotizacionByIdMoneda: function() { | 1396 | getCotizacionByIdMoneda: function() { |
1399 | return { | 1397 | return { |
1400 | then: function() { } | 1398 | then: function() { } |
1401 | }; | 1399 | }; |
1402 | } | 1400 | } |
1403 | }, | 1401 | }, |
1404 | focaBotoneraLateralService: {}, | 1402 | focaBotoneraLateralService: {}, |
1405 | focaModalService: {}, | 1403 | focaModalService: {}, |
1406 | notaPedidoBusinessService: {}, | 1404 | notaPedidoBusinessService: {}, |
1407 | $rootScope: { | 1405 | $rootScope: { |
1408 | $on: function() { } | 1406 | $on: function() { } |
1409 | }, | 1407 | }, |
1410 | focaSeguimientoService: {}, | 1408 | focaSeguimientoService: {}, |
1411 | APP: {}, | 1409 | APP: {}, |
1412 | focaLoginService: {}, | 1410 | focaLoginService: {}, |
1413 | $localStorage: {} | 1411 | $localStorage: {} |
1414 | }); | 1412 | }); |
1415 | 1413 | ||
1416 | scope.notaPedido = {}; | 1414 | scope.notaPedido = {}; |
1417 | 1415 | ||
1418 | var respuesta = { result: {then: function() { } } }; | 1416 | var respuesta = { result: {then: function() { } } }; |
1419 | 1417 | ||
1420 | //act | 1418 | //act |
1421 | spyOn(uibModal, 'open').and.returnValue(respuesta); | 1419 | spyOn(uibModal, 'open').and.returnValue(respuesta); |
1422 | scope.abrirModalCotizacion(); | 1420 | scope.abrirModalCotizacion(); |
1423 | 1421 | ||
1424 | //assert | 1422 | //assert |
1425 | expect(uibModal.open).toHaveBeenCalled(); | 1423 | expect(uibModal.open).toHaveBeenCalled(); |
1426 | }); | 1424 | }); |
1427 | 1425 | ||
1428 | it('función abrirModalCotizacion setea datos y cabecera', function(done) { | 1426 | it('función abrirModalCotizacion setea datos y cabecera', function(done) { |
1429 | //arrange | 1427 | //arrange |
1430 | var scope = { | 1428 | var scope = { |
1431 | $watch: function() { }, | 1429 | $watch: function() { }, |
1432 | $broadcast: function() { } | 1430 | $broadcast: function() { } |
1433 | }; | 1431 | }; |
1434 | var uibModal = { | 1432 | var uibModal = { |
1435 | open: function() { } | 1433 | open: function() { } |
1436 | }; | 1434 | }; |
1437 | 1435 | ||
1438 | $controler('notaPedidoCtrl', { | 1436 | $controler('notaPedidoCtrl', { |
1439 | $scope: scope, | 1437 | $scope: scope, |
1440 | $uibModal: uibModal, | 1438 | $uibModal: uibModal, |
1441 | $location: {}, | 1439 | $location: {}, |
1442 | $filter: filter, | 1440 | $filter: filter, |
1443 | $timeout: timeout, | 1441 | $timeout: timeout, |
1444 | crearNotaPedidoService: { | 1442 | crearNotaPedidoService: { |
1445 | getNumeroNotaPedido: function() { | 1443 | getNumeroNotaPedido: function() { |
1446 | return { | 1444 | return { |
1447 | then: function() { } | 1445 | then: function() { } |
1448 | }; | 1446 | }; |
1449 | }, | 1447 | }, |
1450 | getBotonera: function() { }, | 1448 | getBotonera: function() { }, |
1451 | getCotizacionByIdMoneda: function() { | 1449 | getCotizacionByIdMoneda: function() { |
1452 | return { | 1450 | return { |
1453 | then: function() { } | 1451 | then: function() { } |
1454 | }; | 1452 | }; |
1455 | } | 1453 | } |
1456 | }, | 1454 | }, |
1457 | focaBotoneraLateralService: {}, | 1455 | focaBotoneraLateralService: {}, |
1458 | focaModalService: {}, | 1456 | focaModalService: {}, |
1459 | notaPedidoBusinessService: {}, | 1457 | notaPedidoBusinessService: {}, |
1460 | $rootScope: { | 1458 | $rootScope: { |
1461 | $on: function() { } | 1459 | $on: function() { } |
1462 | }, | 1460 | }, |
1463 | focaSeguimientoService: {}, | 1461 | focaSeguimientoService: {}, |
1464 | APP: {}, | 1462 | APP: {}, |
1465 | focaLoginService: {}, | 1463 | focaLoginService: {}, |
1466 | $localStorage: {}, | 1464 | $localStorage: {}, |
1467 | articulosNotaPedido: [] | 1465 | articulosNotaPedido: [] |
1468 | }); | 1466 | }); |
1469 | 1467 | ||
1470 | scope.notaPedido = {}; | 1468 | scope.notaPedido = {}; |
1471 | scope.articulosTabla = []; | 1469 | scope.articulosTabla = []; |
1472 | scope.$broadcast = function() { }; | 1470 | scope.$broadcast = function() { }; |
1473 | var moneda = 'moneda'; | 1471 | var moneda = 'moneda'; |
1474 | var cotizacion = 'test'; | 1472 | var cotizacion = 'test'; |
1475 | var promesaRespuesta = { result: Promise.resolve(cotizacion) }; | 1473 | var promesaRespuesta = { result: Promise.resolve(cotizacion) }; |
1476 | 1474 | ||
1477 | //act | 1475 | //act |
1478 | spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); | 1476 | spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); |
1479 | spyOn(scope, '$broadcast'); | 1477 | spyOn(scope, '$broadcast'); |
1480 | scope.abrirModalCotizacion(moneda); | 1478 | scope.abrirModalCotizacion(moneda); |
1481 | 1479 | ||
1482 | //assert | 1480 | //assert |
1483 | promesaRespuesta.result.then(function() { | 1481 | promesaRespuesta.result.then(function() { |
1484 | 1482 | ||
1485 | expect(scope.$broadcast).toHaveBeenCalled(); | 1483 | expect(scope.$broadcast).toHaveBeenCalled(); |
1486 | expect(scope.notaPedido.cotizacion).toEqual(cotizacion); | 1484 | expect(scope.notaPedido.cotizacion).toEqual(cotizacion); |
1487 | done(); | 1485 | done(); |
1488 | }); | 1486 | }); |
1489 | }); | 1487 | }); |
1490 | 1488 | ||
1491 | it('función agregarATabla muestra alerta cuando a cargar undefined', function() { | 1489 | it('función agregarATabla muestra alerta cuando a cargar undefined', function() { |
1492 | 1490 | ||
1493 | //arrange | 1491 | //arrange |
1494 | var scope = { | 1492 | var scope = { |
1495 | $watch: function() { }, | 1493 | $watch: function() { }, |
1496 | $broadcast: function() { } | 1494 | $broadcast: function() { } |
1497 | }; | 1495 | }; |
1498 | var focaModalService = { | 1496 | var focaModalService = { |
1499 | alert: function() { } | 1497 | alert: function() { } |
1500 | }; | 1498 | }; |
1501 | 1499 | ||
1502 | $controler('notaPedidoCtrl', { | 1500 | $controler('notaPedidoCtrl', { |
1503 | $scope: scope, | 1501 | $scope: scope, |
1504 | $uibModal: {}, | 1502 | $uibModal: {}, |
1505 | $location: {}, | 1503 | $location: {}, |
1506 | $filter: filter, | 1504 | $filter: filter, |
1507 | $timeout: timeout, | 1505 | $timeout: timeout, |
1508 | crearNotaPedidoService: { | 1506 | crearNotaPedidoService: { |
1509 | getNumeroNotaPedido: function() { | 1507 | getNumeroNotaPedido: function() { |
1510 | return { | 1508 | return { |
1511 | then: function() { } | 1509 | then: function() { } |
1512 | }; | 1510 | }; |
1513 | }, | 1511 | }, |
1514 | getBotonera: function() { }, | 1512 | getBotonera: function() { }, |
1515 | getCotizacionByIdMoneda: function() { | 1513 | getCotizacionByIdMoneda: function() { |
1516 | return { | 1514 | return { |
1517 | then: function() { } | 1515 | then: function() { } |
1518 | }; | 1516 | }; |
1519 | } | 1517 | } |
1520 | }, | 1518 | }, |
1521 | focaBotoneraLateralService: {}, | 1519 | focaBotoneraLateralService: {}, |
1522 | focaModalService: focaModalService, | 1520 | focaModalService: focaModalService, |
1523 | notaPedidoBusinessService: {}, | 1521 | notaPedidoBusinessService: {}, |
1524 | $rootScope: { | 1522 | $rootScope: { |
1525 | $on: function() { } | 1523 | $on: function() { } |
1526 | }, | 1524 | }, |
1527 | focaSeguimientoService: {}, | 1525 | focaSeguimientoService: {}, |
1528 | APP: {}, | 1526 | APP: {}, |
1529 | focaLoginService: {}, | 1527 | focaLoginService: {}, |
1530 | $localStorage: {} | 1528 | $localStorage: {} |
1531 | }); | 1529 | }); |
1532 | scope.articuloACargar = {}; | 1530 | scope.articuloACargar = {}; |
1533 | 1531 | ||
1534 | //act | 1532 | //act |
1535 | spyOn(focaModalService, 'alert'); | 1533 | spyOn(focaModalService, 'alert'); |
1536 | scope.agregarATabla(13); | 1534 | scope.agregarATabla(13); |
1537 | 1535 | ||
1538 | //assert | 1536 | //assert |
1539 | expect(focaModalService.alert).toHaveBeenCalledWith('El valor debe ser al menos 1'); | 1537 | expect(focaModalService.alert).toHaveBeenCalledWith('El valor debe ser al menos 1'); |
1540 | }); | 1538 | }); |
1541 | 1539 | ||
1542 | it('función editarArticulo muestra alerta cuando a cargar es undefined', function() { | 1540 | it('función editarArticulo muestra alerta cuando a cargar es undefined', function() { |
1543 | 1541 | ||
1544 | //arrange | 1542 | //arrange |
1545 | var scope = { | 1543 | var scope = { |
1546 | $watch: function() { }, | 1544 | $watch: function() { }, |
1547 | $broadcast: function() { } | 1545 | $broadcast: function() { } |
1548 | }; | 1546 | }; |
1549 | var focaModalService = { | 1547 | var focaModalService = { |
1550 | alert: function() { } | 1548 | alert: function() { } |
1551 | }; | 1549 | }; |
1552 | 1550 | ||
1553 | $controler('notaPedidoCtrl', { | 1551 | $controler('notaPedidoCtrl', { |
1554 | $scope: scope, | 1552 | $scope: scope, |
1555 | $uibModal: {}, | 1553 | $uibModal: {}, |
1556 | $location: {}, | 1554 | $location: {}, |
1557 | $filter: filter, | 1555 | $filter: filter, |
1558 | $timeout: timeout, | 1556 | $timeout: timeout, |
1559 | crearNotaPedidoService: { | 1557 | crearNotaPedidoService: { |
1560 | getNumeroNotaPedido: function() { | 1558 | getNumeroNotaPedido: function() { |
1561 | return { | 1559 | return { |
1562 | then: function() { } | 1560 | then: function() { } |
1563 | }; | 1561 | }; |
1564 | }, | 1562 | }, |
1565 | getBotonera: function() { }, | 1563 | getBotonera: function() { }, |
1566 | getCotizacionByIdMoneda: function() { | 1564 | getCotizacionByIdMoneda: function() { |
1567 | return { | 1565 | return { |
1568 | then: function() { } | 1566 | then: function() { } |
1569 | }; | 1567 | }; |
1570 | } | 1568 | } |
1571 | }, | 1569 | }, |
1572 | focaBotoneraLateralService: {}, | 1570 | focaBotoneraLateralService: {}, |
1573 | focaModalService: focaModalService, | 1571 | focaModalService: focaModalService, |
1574 | notaPedidoBusinessService: {}, | 1572 | notaPedidoBusinessService: {}, |
1575 | $rootScope: { | 1573 | $rootScope: { |
1576 | $on: function() { } | 1574 | $on: function() { } |
1577 | }, | 1575 | }, |
1578 | focaSeguimientoService: {}, | 1576 | focaSeguimientoService: {}, |
1579 | APP: {}, | 1577 | APP: {}, |
1580 | focaLoginService: {}, | 1578 | focaLoginService: {}, |
1581 | $localStorage: {} | 1579 | $localStorage: {} |
1582 | }); | 1580 | }); |
1583 | scope.articuloACargar = {}; | 1581 | scope.articuloACargar = {}; |
1584 | 1582 | ||
1585 | //act | 1583 | //act |
1586 | spyOn(focaModalService, 'alert'); | 1584 | spyOn(focaModalService, 'alert'); |
1587 | scope.agregarATabla(13); | 1585 | scope.agregarATabla(13); |
1588 | 1586 | ||
1589 | //assert | 1587 | //assert |
1590 | expect(focaModalService.alert).toHaveBeenCalledWith('El valor debe ser al menos 1'); | 1588 | expect(focaModalService.alert).toHaveBeenCalledWith('El valor debe ser al menos 1'); |
1591 | }); | 1589 | }); |
1592 | 1590 | ||
1593 | it('función salir lleva a ruta correcta', function() { | 1591 | it('función salir lleva a ruta correcta', function() { |
1594 | 1592 | ||
1595 | inject(function($location) { | 1593 | inject(function($location) { |
1596 | 1594 | ||
1597 | //arrange | 1595 | //arrange |
1598 | var scope = { | 1596 | var scope = { |
1599 | $watch: function() { }, | 1597 | $watch: function() { }, |
1600 | $broadcast: function() { } | 1598 | $broadcast: function() { } |
1601 | }; | 1599 | }; |
1602 | 1600 | ||
1603 | $controler('notaPedidoCtrl', { | 1601 | $controler('notaPedidoCtrl', { |
1604 | $scope: scope, | 1602 | $scope: scope, |
1605 | $uibModal: {}, | 1603 | $uibModal: {}, |
1606 | $location: $location, | 1604 | $location: $location, |
1607 | $filter: filter, | 1605 | $filter: filter, |
1608 | $timeout: timeout, | 1606 | $timeout: timeout, |
1609 | crearNotaPedidoService: { | 1607 | crearNotaPedidoService: { |
1610 | getNumeroNotaPedido: function() { | 1608 | getNumeroNotaPedido: function() { |
1611 | return { | 1609 | return { |
1612 | then: function() { } | 1610 | then: function() { } |
1613 | }; | 1611 | }; |
1614 | }, | 1612 | }, |
1615 | getBotonera: function() { }, | 1613 | getBotonera: function() { }, |
1616 | getCotizacionByIdMoneda: function() { | 1614 | getCotizacionByIdMoneda: function() { |
1617 | return { | 1615 | return { |
1618 | then: function() { } | 1616 | then: function() { } |
1619 | }; | 1617 | }; |
1620 | } | 1618 | } |
1621 | }, | 1619 | }, |
1622 | focaBotoneraLateralService: {}, | 1620 | focaBotoneraLateralService: {}, |
1623 | focaModalService: {}, | 1621 | focaModalService: {}, |
1624 | notaPedidoBusinessService: {}, | 1622 | notaPedidoBusinessService: {}, |
1625 | $rootScope: { | 1623 | $rootScope: { |
1626 | $on: function() { } | 1624 | $on: function() { } |
1627 | }, | 1625 | }, |
1628 | focaSeguimientoService: {}, | 1626 | focaSeguimientoService: {}, |
1629 | APP: {}, | 1627 | APP: {}, |
1630 | focaLoginService: {}, | 1628 | focaLoginService: {}, |
1631 | $localStorage: {}, | 1629 | $localStorage: {}, |
1632 | }); | 1630 | }); |
1633 | 1631 | ||
1634 | //act | 1632 | //act |
1635 | scope.salir(); | 1633 | scope.salir(); |
1636 | 1634 | ||
1637 | //assert | 1635 | //assert |
1638 | expect($location.url()).toEqual('/'); | 1636 | expect($location.url()).toEqual('/'); |
1639 | }); | 1637 | }); |
1640 | }); | 1638 | }); |
1641 | }); | 1639 | }); |
1642 | }); | 1640 | }); |
1643 | 1641 |