[ADF-3181] Auth Guard - redirect by string url (#3474)

* redirect by string url

* auth guard tests fix

* revise
This commit is contained in:
Cilibiu Bogdan
2018-06-14 12:19:34 +03:00
committed by Eugenio Romano
parent 0cf2a35983
commit c0de0d5087
12 changed files with 55 additions and 111 deletions

View File

@@ -68,7 +68,7 @@ describe('AuthGuardService BPM', () => {
expect(routerService.navigate).toHaveBeenCalledWith(['/login']);
}));
it('should set redirect navigation commands', async(() => {
it('should set redirect url', async(() => {
spyOn(authService, 'setRedirect').and.callThrough();
spyOn(routerService, 'navigate').and.stub();
const router: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' };
@@ -76,9 +76,9 @@ describe('AuthGuardService BPM', () => {
authGuard.canActivate(null, router);
expect(authService.setRedirect).toHaveBeenCalledWith({
provider: 'BPM', navigation: ['some-url', {}]
provider: 'BPM', url: 'some-url'
});
expect(authService.getRedirect('BPM')).toEqual(['some-url', {}]);
expect(authService.getRedirect('BPM')).toEqual('some-url');
}));
it('should set redirect navigation commands with query params', async(() => {
@@ -89,9 +89,9 @@ describe('AuthGuardService BPM', () => {
authGuard.canActivate(null, router);
expect(authService.setRedirect).toHaveBeenCalledWith({
provider: 'BPM', navigation: ['some-url', {q: '123'}]
provider: 'BPM', url: 'some-url;q=123'
});
expect(authService.getRedirect('BPM')).toEqual(['some-url', { q: '123' }]);
expect(authService.getRedirect('BPM')).toEqual('some-url;q=123');
}));
it('should set redirect navigation commands with query params', async(() => {
@@ -102,9 +102,9 @@ describe('AuthGuardService BPM', () => {
authGuard.canActivate(null, router);
expect(authService.setRedirect).toHaveBeenCalledWith({
provider: 'BPM', navigation: ['/']
provider: 'BPM', url: '/'
});
expect(authService.getRedirect('BPM')).toEqual(['/']);
expect(authService.getRedirect('BPM')).toEqual('/');
}));
it('should get redirect url from config if there is one configured', async(() => {
@@ -116,7 +116,7 @@ describe('AuthGuardService BPM', () => {
authGuard.canActivate(null, router);
expect(authService.setRedirect).toHaveBeenCalledWith({
provider: 'BPM', navigation: ['some-url', {}]
provider: 'BPM', url: 'some-url'
});
expect(routerService.navigate).toHaveBeenCalledWith(['/fakeLoginRoute']);
}));