Commits
Art Lowel authored and GitHub committed ce31ef0d0f5 Merge
242 242 | expect(storage.set).toHaveBeenCalled(); |
243 243 | }); |
244 244 | |
245 245 | it('should remove token from storage', () => { |
246 246 | authService.removeToken(); |
247 247 | expect(storage.remove).toHaveBeenCalled(); |
248 248 | }); |
249 249 | |
250 250 | it ('should set redirect url to previous page', () => { |
251 251 | spyOn(routeServiceMock, 'getHistory').and.callThrough(); |
252 + | spyOn(routerStub, 'navigateByUrl'); |
252 253 | authService.redirectAfterLoginSuccess(true); |
253 254 | expect(routeServiceMock.getHistory).toHaveBeenCalled(); |
254 - | expect(routerStub.navigate).toHaveBeenCalledWith(['/collection/123']); |
255 + | expect(routerStub.navigateByUrl).toHaveBeenCalledWith('/collection/123'); |
255 256 | }); |
256 257 | |
257 258 | it ('should set redirect url to current page', () => { |
258 259 | spyOn(routeServiceMock, 'getHistory').and.callThrough(); |
260 + | spyOn(routerStub, 'navigateByUrl'); |
259 261 | authService.redirectAfterLoginSuccess(false); |
260 262 | expect(routeServiceMock.getHistory).toHaveBeenCalled(); |
261 - | expect(routerStub.navigate).toHaveBeenCalledWith(['/home']); |
263 + | expect(routerStub.navigateByUrl).toHaveBeenCalledWith('/home'); |
262 264 | }); |
263 265 | |
264 266 | it ('should redirect to / and not to /login', () => { |
265 267 | spyOn(routeServiceMock, 'getHistory').and.returnValue(observableOf(['/login', '/login'])); |
268 + | spyOn(routerStub, 'navigateByUrl'); |
266 269 | authService.redirectAfterLoginSuccess(true); |
267 270 | expect(routeServiceMock.getHistory).toHaveBeenCalled(); |
268 - | expect(routerStub.navigate).toHaveBeenCalledWith(['/']); |
271 + | expect(routerStub.navigateByUrl).toHaveBeenCalledWith('/'); |
269 272 | }); |
270 273 | |
271 274 | it ('should redirect to / when no redirect url is found', () => { |
272 275 | spyOn(routeServiceMock, 'getHistory').and.returnValue(observableOf([''])); |
276 + | spyOn(routerStub, 'navigateByUrl'); |
273 277 | authService.redirectAfterLoginSuccess(true); |
274 278 | expect(routeServiceMock.getHistory).toHaveBeenCalled(); |
275 - | expect(routerStub.navigate).toHaveBeenCalledWith(['/']); |
279 + | expect(routerStub.navigateByUrl).toHaveBeenCalledWith('/'); |
276 280 | }); |
277 281 | }); |
278 282 | }); |