Commit e5e532b1f8eaf3288eba61d3d0cd990718696cf7
1 parent
a08587385b
Exists in
master
Arreglo de errores Test
Showing
1 changed file
with
49 additions
and
11 deletions
Show diff stats
spec/controllerSpec.js
1 | describe('Controladores abm precios condiciones', function() { | 1 | describe('Controladores abm precios condiciones', function() { |
2 | 2 | ||
3 | var $controller; | 3 | var $controller; |
4 | var timeout; | 4 | var timeout; |
5 | 5 | ||
6 | beforeEach(function() { | 6 | beforeEach(function() { |
7 | module('focaAbmPreciosCondiciones'); | 7 | module('focaAbmPreciosCondiciones'); |
8 | inject(function(_$controller_) { | 8 | inject(function(_$controller_) { |
9 | $controller = _$controller_; | 9 | $controller = _$controller_; |
10 | }); | 10 | }); |
11 | }); | 11 | }); |
12 | 12 | ||
13 | beforeEach(function() { | 13 | beforeEach(function() { |
14 | inject(function($timeout) { | 14 | inject(function($timeout) { |
15 | timeout = $timeout; | 15 | timeout = $timeout; |
16 | }); | 16 | }); |
17 | }); | 17 | }); |
18 | 18 | ||
19 | describe('Controlador focaAbmPreciosCondiciones', function() { | 19 | describe('Controlador focaAbmPreciosCondiciones', function() { |
20 | 20 | ||
21 | it('Existe el controlador', function() { | 21 | it('Existe el controlador', function() { |
22 | //act | 22 | //act |
23 | var controlador = $controller('focaAbmPreciosCondicionesController', { | 23 | var controlador = $controller('focaAbmPreciosCondicionesController', { |
24 | $scope: {}, | 24 | $scope: {}, |
25 | focaAbmPreciosCondicionesService: {}, | 25 | focaAbmPreciosCondicionesService: {}, |
26 | $location: {}, | 26 | $location: {}, |
27 | focaModalService: {}, | 27 | focaModalService: {}, |
28 | $localStorage: {}, | ||
28 | focaBotoneraLateralService: {}, | 29 | focaBotoneraLateralService: {}, |
29 | $timeout: timeout | 30 | $timeout: timeout |
30 | }); | 31 | }); |
31 | 32 | ||
32 | //assert | 33 | //assert |
33 | expect(typeof controlador).toEqual('object'); | 34 | expect(typeof controlador).toEqual('object'); |
34 | }); | 35 | }); |
35 | 36 | ||
36 | it('$scope.editar lleva a la ruta correcta', function() { | 37 | it('$scope.editar lleva a la ruta correcta', function() { |
37 | inject(function($location) { | 38 | inject(function($location) { |
38 | //arrange | 39 | //arrange |
39 | var scope = {}; | 40 | var scope = {}; |
40 | var paramFake = 1; | 41 | var paramFake = 1; |
41 | $controller('focaAbmPreciosCondicionesController', { | 42 | $controller('focaAbmPreciosCondicionesController', { |
42 | $scope: scope, | 43 | $scope: scope, |
43 | focaAbmPreciosCondicionesService: {}, | 44 | focaAbmPreciosCondicionesService: {}, |
44 | $location: $location, | 45 | $location: $location, |
46 | $localStorage: {}, | ||
45 | focaModalService: {}, | 47 | focaModalService: {}, |
46 | focaBotoneraLateralService: {}, | 48 | focaBotoneraLateralService: {}, |
47 | $timeout: timeout | 49 | $timeout: timeout |
48 | }); | 50 | }); |
49 | 51 | ||
50 | 52 | ||
51 | //act | 53 | //act |
52 | scope.editar(paramFake); | 54 | scope.editar(paramFake); |
53 | 55 | ||
54 | //assert | 56 | //assert |
55 | expect($location.url()).toEqual('/precio-condicion/' + paramFake); | 57 | expect($location.url()).toEqual('/precio-condicion/' + paramFake); |
56 | }); | 58 | }); |
57 | }); | 59 | }); |
58 | 60 | ||
59 | it('$scope.solicitarConfirmacion levanta modal confirm', function() { | 61 | it('$scope.solicitarConfirmacion levanta modal confirm', function() { |
60 | //arrange | 62 | //arrange |
61 | var scope = {}; | 63 | var scope = {}; |
62 | var paramFake = 1; | 64 | var paramFake = 1; |
63 | var focaModalService = { | 65 | var focaModalService = { |
64 | confirm: function() { } | 66 | confirm: function() { } |
65 | }; | 67 | }; |
66 | $controller('focaAbmPreciosCondicionesController', { | 68 | $controller('focaAbmPreciosCondicionesController', { |
67 | $scope: scope, | 69 | $scope: scope, |
68 | focaAbmPreciosCondicionesService: {}, | 70 | focaAbmPreciosCondicionesService: {}, |
69 | $location: {}, | 71 | $location: {}, |
72 | $localStorage: {}, | ||
70 | focaModalService: focaModalService, | 73 | focaModalService: focaModalService, |
71 | focaBotoneraLateralService: {}, | 74 | focaBotoneraLateralService: {}, |
72 | $timeout: timeout | 75 | $timeout: timeout |
73 | }); | 76 | }); |
74 | 77 | ||
75 | //act | 78 | //act |
76 | spyOn(focaModalService, 'confirm').and.returnValue({ then: function() { }}); | 79 | spyOn(focaModalService, 'confirm').and.returnValue({ then: function() { }}); |
77 | scope.solicitarConfirmacion(paramFake); | 80 | scope.solicitarConfirmacion(paramFake); |
78 | 81 | ||
79 | //assert | 82 | //assert |
80 | expect(focaModalService.confirm).toHaveBeenCalled(); | 83 | expect(focaModalService.confirm).toHaveBeenCalled(); |
81 | }); | 84 | }); |
82 | 85 | ||
83 | it('$scope.solicitarConfirmacion elimina al confirmar ok', function(done) { | 86 | it('$scope.solicitarConfirmacion elimina al confirmar ok', function(done) { |
84 | //arrange | 87 | //arrange |
85 | var scope = {}; | 88 | var scope = {}; |
86 | var paramFake = 1; | 89 | var paramFake = 1; |
87 | var focaModalService = { | 90 | var focaModalService = { |
88 | confirm: function() { } | 91 | confirm: function() { } |
89 | }; | 92 | }; |
90 | var focaAbmPreciosCondicionesService = { | 93 | var focaAbmPreciosCondicionesService = { |
91 | borrarPrecioCondicion: function() { } | 94 | borrarPrecioCondicion: function() { } |
92 | }; | 95 | }; |
93 | $controller('focaAbmPreciosCondicionesController', { | 96 | $controller('focaAbmPreciosCondicionesController', { |
94 | $scope: scope, | 97 | $scope: scope, |
95 | focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, | 98 | focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, |
96 | $location: {}, | 99 | $location: {}, |
100 | $localStorage: {}, | ||
97 | focaModalService: focaModalService, | 101 | focaModalService: focaModalService, |
98 | focaBotoneraLateralService: {}, | 102 | focaBotoneraLateralService: {}, |
99 | $timeout: timeout | 103 | $timeout: timeout |
100 | }); | 104 | }); |
101 | var promesaConfirm = Promise.resolve(true); | 105 | var promesaConfirm = Promise.resolve(true); |
102 | scope.preciosCondiciones = []; | 106 | scope.preciosCondiciones = []; |
103 | 107 | ||
104 | //act | 108 | //act |
105 | spyOn(focaModalService, 'confirm').and.returnValue(promesaConfirm); | 109 | spyOn(focaModalService, 'confirm').and.returnValue(promesaConfirm); |
106 | spyOn(focaAbmPreciosCondicionesService, 'borrarPrecioCondicion'); | 110 | spyOn(focaAbmPreciosCondicionesService, 'borrarPrecioCondicion'); |
107 | scope.solicitarConfirmacion(paramFake); | 111 | scope.solicitarConfirmacion(paramFake); |
108 | 112 | ||
109 | //assert | 113 | //assert |
110 | promesaConfirm.then(function() { | 114 | promesaConfirm.then(function() { |
111 | expect(focaAbmPreciosCondicionesService.borrarPrecioCondicion).toHaveBeenCalled(); | 115 | expect(focaAbmPreciosCondicionesService.borrarPrecioCondicion).toHaveBeenCalled(); |
112 | done(); | 116 | done(); |
113 | }); | 117 | }); |
114 | }); | 118 | }); |
115 | 119 | ||
116 | it('$scope.buscar llama a obtenerPreciosCondiciones', function() { | 120 | it('$scope.buscar llama a obtenerPreciosCondiciones', function() { |
117 | //arrange | 121 | //arrange |
118 | var scope = {}; | 122 | var scope = {}; |
119 | var focaAbmPreciosCondicionesService = { | 123 | var focaAbmPreciosCondicionesService = { |
120 | obtenerPreciosCondiciones: function() { } | 124 | obtenerPreciosCondiciones: function() { } |
121 | }; | 125 | }; |
122 | $controller('focaAbmPreciosCondicionesController', { | 126 | $controller('focaAbmPreciosCondicionesController', { |
123 | $scope: scope, | 127 | $scope: scope, |
124 | focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, | 128 | focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, |
125 | $location: {}, | 129 | $location: {}, |
130 | $localStorage: {}, | ||
126 | focaModalService: {}, | 131 | focaModalService: {}, |
127 | focaBotoneraLateralService: {}, | 132 | focaBotoneraLateralService: {}, |
128 | $timeout: timeout | 133 | $timeout: timeout |
129 | }); | 134 | }); |
130 | 135 | ||
131 | //act | 136 | //act |
132 | spyOn(focaAbmPreciosCondicionesService, 'obtenerPreciosCondiciones') | 137 | spyOn(focaAbmPreciosCondicionesService, 'obtenerPreciosCondiciones') |
133 | .and.returnValue({ then: function() { }}); | 138 | .and.returnValue({ then: function() { }}); |
134 | scope.buscar(13); | 139 | scope.buscar(13); |
135 | 140 | ||
136 | //assert | 141 | //assert |
137 | expect(focaAbmPreciosCondicionesService.obtenerPreciosCondiciones).toHaveBeenCalled(); | 142 | expect(focaAbmPreciosCondicionesService.obtenerPreciosCondiciones).toHaveBeenCalled(); |
138 | }); | 143 | }); |
139 | }); | 144 | }); |
140 | 145 | ||
141 | describe('Controlador focaAbmPrecioCondicionController', function() { | 146 | describe('Controlador focaAbmPrecioCondicionController', function() { |
142 | 147 | ||
143 | it('Existe el controlador focaAbmPrecioCondicionController', function() { | 148 | it('Existe el controlador focaAbmPrecioCondicionController', function() { |
144 | //act | 149 | //act |
145 | var controlador = $controller('focaAbmPrecioCondicionController', { | 150 | var controlador = $controller('focaAbmPrecioCondicionController', { |
146 | $scope: {}, | 151 | $scope: { |
152 | $watch: function(){} | ||
153 | }, | ||
147 | focaAbmPreciosCondicionesService: { | 154 | focaAbmPreciosCondicionesService: { |
148 | obtenerPrecioCondicion: function() { | 155 | obtenerPrecioCondicion: function() { |
149 | return { | 156 | return { |
150 | then: function() { } | 157 | then: function() { } |
151 | }; | 158 | }; |
152 | } | 159 | } |
153 | }, | 160 | }, |
154 | focaBotoneraLateralService: {}, | 161 | focaBotoneraLateralService: {}, |
155 | $routeParams: {}, | 162 | $routeParams: {}, |
156 | $location: {}, | 163 | $location: {}, |
157 | focaModalService: {}, | 164 | focaModalService: {}, |
158 | $timeout: timeout, | 165 | $timeout: timeout, |
159 | $uibModal: {}, | 166 | $uibModal: {}, |
167 | $localStorage: {}, | ||
160 | $window: {} | 168 | $window: {} |
161 | }); | 169 | }); |
162 | 170 | ||
163 | //assert | 171 | //assert |
164 | expect(typeof controlador).toEqual('object'); | 172 | expect(typeof controlador).toEqual('object'); |
165 | }); | 173 | }); |
166 | 174 | ||
167 | it('La funcion $scope.cancelar lleva a la ruta correcta', function() { | 175 | it('La funcion $scope.cancelar lleva a la ruta correcta', function() { |
168 | inject(function($location) { | 176 | inject(function($location) { |
169 | //arrange | 177 | //arrange |
170 | var scope = {}; | 178 | var scope = { |
179 | $watch: function() {}, | ||
180 | salir: function() {}, | ||
181 | formPrecioCondicion: '' | ||
182 | }; | ||
171 | $controller('focaAbmPrecioCondicionController', { | 183 | $controller('focaAbmPrecioCondicionController', { |
172 | $scope: scope, | 184 | $scope: scope, |
173 | focaAbmPreciosCondicionesService: { | 185 | focaAbmPreciosCondicionesService: { |
174 | obtenerPrecioCondicion: function() { | 186 | obtenerPrecioCondicion: function() { |
175 | return { | 187 | return { |
176 | then: function() { } | 188 | then: function() { } |
177 | }; | 189 | }; |
178 | } | 190 | } |
179 | }, | 191 | }, |
180 | focaBotoneraLateralService: {}, | 192 | focaBotoneraLateralService: {}, |
181 | $routeParams: {}, | 193 | $routeParams: {}, |
182 | $location: $location, | 194 | $location: $location, |
195 | $localStorage: {}, | ||
183 | focaModalService: {}, | 196 | focaModalService: {}, |
184 | $timeout: timeout, | 197 | $timeout: timeout, |
185 | $uibModal: {}, | 198 | $uibModal: {}, |
186 | $window: {} | 199 | $window: {} |
187 | }); | 200 | }); |
188 | 201 | ||
189 | //act | 202 | //act |
190 | scope.cancelar(); | 203 | scope.salir(); |
191 | 204 | ||
192 | //assert | 205 | //assert |
193 | expect($location.url()).toEqual('/precio-condicion'); | 206 | expect($location.url()).toEqual('/precio-condicion'); |
194 | }); | 207 | }); |
195 | }); | 208 | }); |
196 | 209 | ||
197 | it('La funcion $scope.guardar llama a servicio.guardarPrecioCondicion', function() { | 210 | it('La funcion $scope.guardar llama a servicio.guardarPrecioCondicion', function() { |
198 | inject(function($location) { | 211 | inject(function($location) { |
199 | //arrange | 212 | //arrange |
200 | var scope = {}; | 213 | var scope = { |
214 | $watch: function() { } | ||
215 | }; | ||
201 | var focaAbmPreciosCondicionesService = { | 216 | var focaAbmPreciosCondicionesService = { |
202 | obtenerPrecioCondicion: function() { | 217 | obtenerPrecioCondicion: function() { |
203 | return { | 218 | return { |
204 | then: function() { } | 219 | then: function() { } |
205 | }; | 220 | }; |
206 | }, | 221 | }, |
207 | guardarPrecioCondicion: function() { } | 222 | guardarPrecioCondicion: function() { } |
208 | }; | 223 | }; |
209 | var window = { | 224 | var window = { |
210 | location: { | 225 | location: { |
211 | assign: function() { } | 226 | assign: function() { } |
212 | } | 227 | } |
213 | }; | 228 | }; |
214 | $controller('focaAbmPrecioCondicionController', { | 229 | $controller('focaAbmPrecioCondicionController', { |
215 | $scope: scope, | 230 | $scope: scope, |
216 | focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, | 231 | focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, |
217 | focaBotoneraLateralService: {}, | 232 | focaBotoneraLateralService: {}, |
218 | $routeParams: {}, | 233 | $routeParams: {}, |
219 | $location: $location, | 234 | $location: $location, |
220 | focaModalService: {}, | 235 | focaModalService: { |
236 | alert: function() {} | ||
237 | }, | ||
221 | $timeout: timeout, | 238 | $timeout: timeout, |
222 | $uibModal: {}, | 239 | $uibModal: {}, |
240 | $localStorage: {}, | ||
223 | $window: window | 241 | $window: window |
224 | }); | 242 | }); |
225 | var promesaGuardarPrecioCondicion = Promise.resolve(true); | 243 | var promesaGuardarPrecioCondicion = Promise.resolve(true); |
226 | scope.precioCondicion = { listaPrecio: {} }; | 244 | scope.precioCondicion = { |
245 | listaPrecio: {}, | ||
246 | nombre: true, | ||
247 | descripcion: true, | ||
248 | idListaPrecio: true | ||
249 | }; | ||
227 | 250 | ||
228 | //act | 251 | //act |
229 | //spyOn(window, 'location').and.returnValue({ assign: function() {} }); | 252 | //spyOn(window, 'location').and.returnValue({ assign: function() {} }); |
230 | spyOn(focaAbmPreciosCondicionesService, 'guardarPrecioCondicion') | 253 | spyOn(focaAbmPreciosCondicionesService, 'guardarPrecioCondicion') |
231 | .and.returnValue(promesaGuardarPrecioCondicion); | 254 | .and.returnValue(promesaGuardarPrecioCondicion); |
232 | scope.guardar(); | 255 | scope.guardar(); |
233 | 256 | ||
234 | //assert | 257 | //assert |
235 | expect(focaAbmPreciosCondicionesService.guardarPrecioCondicion).toHaveBeenCalled(); | 258 | expect(focaAbmPreciosCondicionesService.guardarPrecioCondicion).toHaveBeenCalled(); |
236 | }); | 259 | }); |
237 | }); | 260 | }); |
238 | 261 | ||
239 | it('La funcion $scope.solicitarConfirmacionPlazoPago levanta modal confirm', function() { | 262 | it('La funcion $scope.solicitarConfirmacionPlazoPago levanta modal confirm', function() { |
240 | //act | 263 | //act |
241 | var scope = {}; | 264 | var scope = { |
265 | $watch: function() {} | ||
266 | }; | ||
242 | var focaModalService = { | 267 | var focaModalService = { |
243 | confirm: function() { } | 268 | confirm: function() { } |
244 | }; | 269 | }; |
245 | $controller('focaAbmPrecioCondicionController', { | 270 | $controller('focaAbmPrecioCondicionController', { |
246 | $scope: scope, | 271 | $scope: scope, |
247 | focaAbmPreciosCondicionesService: { | 272 | focaAbmPreciosCondicionesService: { |
248 | obtenerPrecioCondicion: function() { | 273 | obtenerPrecioCondicion: function() { |
249 | return { | 274 | return { |
250 | then:function() { } | 275 | then:function() { } |
251 | }; | 276 | }; |
252 | } | 277 | } |
253 | }, | 278 | }, |
254 | focaBotoneraLateralService: {}, | 279 | focaBotoneraLateralService: {}, |
255 | $routeParams: {}, | 280 | $routeParams: {}, |
256 | $location: {}, | 281 | $location: {}, |
257 | focaModalService: focaModalService, | 282 | focaModalService: focaModalService, |
258 | $timeout: timeout, | 283 | $timeout: timeout, |
259 | $uibModal: {}, | 284 | $uibModal: {}, |
285 | $localStorage: {}, | ||
260 | $window: {} | 286 | $window: {} |
261 | }); | 287 | }); |
262 | 288 | ||
263 | //act | 289 | //act |
264 | spyOn(focaModalService, 'confirm') | 290 | spyOn(focaModalService, 'confirm') |
265 | .and.returnValue({ then: function() {} }); | 291 | .and.returnValue({ then: function() {} }); |
266 | scope.solicitarConfirmacionPlazoPago({ data: 'test' }); | 292 | scope.solicitarConfirmacionPlazoPago({ data: 'test' }); |
267 | 293 | ||
268 | //assert | 294 | //assert |
269 | expect(focaModalService.confirm).toHaveBeenCalled(); | 295 | expect(focaModalService.confirm).toHaveBeenCalled(); |
270 | }); | 296 | }); |
271 | 297 | ||
272 | it('La funcion $scope.solicitarConfirmacionPlazoPago borra al dar ok', function(done) { | 298 | it('La funcion $scope.solicitarConfirmacionPlazoPago borra al dar ok', function(done) { |
273 | //act | 299 | //act |
274 | var scope = {}; | 300 | var scope = { |
301 | $watch: function() { } | ||
302 | }; | ||
275 | var focaModalService = { | 303 | var focaModalService = { |
276 | confirm: function() { } | 304 | confirm: function() { } |
277 | }; | 305 | }; |
278 | var focaAbmPreciosCondicionesService = { | 306 | var focaAbmPreciosCondicionesService = { |
279 | obtenerPrecioCondicion: function() { | 307 | obtenerPrecioCondicion: function() { |
280 | return { | 308 | return { |
281 | then:function() { } | 309 | then:function() { } |
282 | }; | 310 | }; |
283 | }, | 311 | }, |
284 | borrarPlazoPago: function() { } | 312 | borrarPlazoPago: function() { } |
285 | }; | 313 | }; |
286 | $controller('focaAbmPrecioCondicionController', { | 314 | $controller('focaAbmPrecioCondicionController', { |
287 | $scope: scope, | 315 | $scope: scope, |
288 | focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, | 316 | focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, |
289 | focaBotoneraLateralService: {}, | 317 | focaBotoneraLateralService: {}, |
290 | $routeParams: {}, | 318 | $routeParams: {}, |
291 | $location: {}, | 319 | $location: {}, |
292 | focaModalService: focaModalService, | 320 | focaModalService: focaModalService, |
293 | $timeout: timeout, | 321 | $timeout: timeout, |
322 | $localStorage: {}, | ||
294 | $uibModal: {}, | 323 | $uibModal: {}, |
295 | $window: {} | 324 | $window: {} |
296 | }); | 325 | }); |
297 | var promesaConfirm = Promise.resolve(true); | 326 | var promesaConfirm = Promise.resolve(true); |
298 | scope.precioCondicion = { | 327 | scope.precioCondicion = { |
299 | plazos: [] | 328 | plazos: [] |
300 | }; | 329 | }; |
301 | 330 | ||
302 | //act | 331 | //act |
303 | spyOn(focaModalService, 'confirm').and.returnValue(promesaConfirm); | 332 | spyOn(focaModalService, 'confirm').and.returnValue(promesaConfirm); |
304 | spyOn(focaAbmPreciosCondicionesService, 'borrarPlazoPago'); | 333 | spyOn(focaAbmPreciosCondicionesService, 'borrarPlazoPago'); |
305 | scope.solicitarConfirmacionPlazoPago({ data: 'test' }); | 334 | scope.solicitarConfirmacionPlazoPago({ data: 'test' }); |
306 | 335 | ||
307 | //assert | 336 | //assert |
308 | promesaConfirm.then(function() { | 337 | promesaConfirm.then(function() { |
309 | expect(focaAbmPreciosCondicionesService.borrarPlazoPago).toHaveBeenCalled(); | 338 | expect(focaAbmPreciosCondicionesService.borrarPlazoPago).toHaveBeenCalled(); |
310 | done(); | 339 | done(); |
311 | }); | 340 | }); |
312 | }); | 341 | }); |
313 | 342 | ||
314 | it('La funcion $scope.seleccionarListaPrecio levanta modal', function() { | 343 | it('La funcion $scope.seleccionarListaPrecio levanta modal', function() { |
315 | //arrange | 344 | //arrange |
316 | var scope = {}; | 345 | var scope = { |
346 | $watch: function() {} | ||
347 | }; | ||
317 | var uibModal = { | 348 | var uibModal = { |
318 | open: function() { } | 349 | open: function() { } |
319 | }; | 350 | }; |
320 | var focaAbmPreciosCondicionesService = { | 351 | var focaAbmPreciosCondicionesService = { |
321 | obtenerPrecioCondicion: function() { | 352 | obtenerPrecioCondicion: function() { |
322 | return { | 353 | return { |
323 | then:function() { } | 354 | then:function() { } |
324 | }; | 355 | }; |
325 | } | 356 | } |
326 | }; | 357 | }; |
327 | $controller('focaAbmPrecioCondicionController', { | 358 | $controller('focaAbmPrecioCondicionController', { |
328 | $scope: scope, | 359 | $scope: scope, |
329 | focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, | 360 | focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, |
330 | focaBotoneraLateralService: {}, | 361 | focaBotoneraLateralService: {}, |
331 | $routeParams: {}, | 362 | $routeParams: {}, |
332 | $location: {}, | 363 | $location: {}, |
333 | focaModalService: {}, | 364 | focaModalService: {}, |
334 | $timeout: timeout, | 365 | $timeout: timeout, |
335 | $uibModal: uibModal, | 366 | $uibModal: uibModal, |
367 | $localStorage: {}, | ||
336 | $window: {} | 368 | $window: {} |
337 | }); | 369 | }); |
338 | 370 | ||
339 | //act | 371 | //act |
340 | spyOn(uibModal, 'open').and.returnValue({ result: { then: function() { } } }); | 372 | spyOn(uibModal, 'open').and.returnValue({ result: { then: function() { } } }); |
341 | scope.seleccionarListaPrecio(13); | 373 | scope.seleccionarListaPrecio(13); |
342 | 374 | ||
343 | //assert | 375 | //assert |
344 | expect(uibModal.open).toHaveBeenCalled(); | 376 | expect(uibModal.open).toHaveBeenCalled(); |
345 | }); | 377 | }); |
346 | 378 | ||
347 | it('La funcion $scope.verProductosListaPrecio levanta modal', function() { | 379 | it('La funcion $scope.verProductosListaPrecio levanta modal', function() { |
348 | //arrange | 380 | //arrange |
349 | var scope = {}; | 381 | var scope = { |
382 | $watch: function() {} | ||
383 | }; | ||
350 | var uibModal = { | 384 | var uibModal = { |
351 | open: function() { } | 385 | open: function() { } |
352 | }; | 386 | }; |
353 | var focaAbmPreciosCondicionesService = { | 387 | var focaAbmPreciosCondicionesService = { |
354 | obtenerPrecioCondicion: function() { | 388 | obtenerPrecioCondicion: function() { |
355 | return { | 389 | return { |
356 | then:function() { } | 390 | then:function() { } |
357 | }; | 391 | }; |
358 | } | 392 | } |
359 | }; | 393 | }; |
360 | $controller('focaAbmPrecioCondicionController', { | 394 | $controller('focaAbmPrecioCondicionController', { |
361 | $scope: scope, | 395 | $scope: scope, |
362 | focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, | 396 | focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, |
363 | focaBotoneraLateralService: {}, | 397 | focaBotoneraLateralService: {}, |
364 | $routeParams: {}, | 398 | $routeParams: {}, |
365 | $location: {}, | 399 | $location: {}, |
366 | focaModalService: {}, | 400 | focaModalService: {}, |
367 | $timeout: timeout, | 401 | $timeout: timeout, |
368 | $uibModal: uibModal, | 402 | $uibModal: uibModal, |
403 | $localStorage: {}, | ||
369 | $window: {} | 404 | $window: {} |
370 | }); | 405 | }); |
371 | scope.precioCondicion = { | 406 | scope.precioCondicion = { |
372 | listaPrecio: {} | 407 | listaPrecio: {} |
373 | }; | 408 | }; |
374 | //act | 409 | //act |
375 | spyOn(uibModal, 'open'); | 410 | spyOn(uibModal, 'open'); |
376 | scope.verProductosListaPrecio(); | 411 | scope.verProductosListaPrecio(); |
377 | 412 | ||
378 | //assert | 413 | //assert |
379 | expect(uibModal.open).toHaveBeenCalled(); | 414 | expect(uibModal.open).toHaveBeenCalled(); |
380 | }); | 415 | }); |
381 | 416 | ||
382 | it('la función next suma uno a $scope.focused', function() { | 417 | it('la función next suma uno a $scope.focused', function() { |
383 | //arrange | 418 | //arrange |
384 | var scope = {}; | 419 | var scope = { |
420 | $watch: function() {} | ||
421 | }; | ||
385 | var focaAbmPreciosCondicionesService = { | 422 | var focaAbmPreciosCondicionesService = { |
386 | obtenerPrecioCondicion: function() { | 423 | obtenerPrecioCondicion: function() { |
387 | return { | 424 | return { |
388 | then:function() { } | 425 | then:function() { } |
389 | }; | 426 | }; |
390 | } | 427 | } |
391 | }; | 428 | }; |
392 | $controller('focaAbmPrecioCondicionController', { | 429 | $controller('focaAbmPrecioCondicionController', { |
393 | $scope: scope, | 430 | $scope: scope, |
394 | focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, | 431 | focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, |
395 | focaBotoneraLateralService: {}, | 432 | focaBotoneraLateralService: {}, |
396 | $routeParams: {}, | 433 | $routeParams: {}, |
397 | $location: {}, | 434 | $location: {}, |
398 | focaModalService: {}, | 435 | focaModalService: {}, |
399 | $timeout: timeout, | 436 | $timeout: timeout, |
400 | $uibModal: {}, | 437 | $uibModal: {}, |
438 | $localStorage: {}, | ||
401 | $window: {} | 439 | $window: {} |
402 | }); | 440 | }); |
403 | 441 | ||
404 | //act | 442 | //act |
405 | var esperado = scope.focused + 1; | 443 | var esperado = scope.focused + 1; |
406 | scope.next(13); | 444 | scope.next(13); |
407 | 445 | ||
408 | //assert | 446 | //assert |
409 | expect(scope.focused).toEqual(esperado); | 447 | expect(scope.focused).toEqual(esperado); |
410 | }); | 448 | }); |
411 | }); | 449 | }); |
412 | }); | 450 | }); |
413 | 451 |