Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add defaultRedirectTo to configurationService #179

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { fakeAsync, inject, TestBed } from '@angular/core/testing';
import { ActivatedRouteSnapshot, Router, RouterStateSnapshot } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { NgxPermissionsModule } from '../index';
import {NgxPermissionsConfigurationService, NgxPermissionsModule} from '../index';
import { NgxPermissionsService } from '../service/permissions.service';
import { NgxRolesService } from '../service/roles.service';
import { NgxPermissionsGuard } from './permissions-guard.service';
Expand All @@ -16,15 +16,15 @@ describe('Permissions guard only', () => {
imports: [NgxPermissionsModule.forRoot()]
});
});
beforeEach(inject([NgxPermissionsService, NgxRolesService], (service: NgxPermissionsService, rolesService: NgxRolesService) => {
beforeEach(inject([NgxPermissionsService, NgxRolesService, NgxPermissionsConfigurationService], (service: NgxPermissionsService, rolesService: NgxRolesService, configurationService: NgxPermissionsConfigurationService) => {
fakeRouter = {
navigate: () => {
}
} as any;
spyOn(fakeRouter, 'navigate');

service.addPermission('ADMIN');
permissionGuard = new NgxPermissionsGuard(service, rolesService, fakeRouter as Router);
permissionGuard = new NgxPermissionsGuard(service, rolesService, fakeRouter as Router, configurationService);
}));

it('should create an instance', () => {
Expand Down Expand Up @@ -124,15 +124,15 @@ describe('Permissions guard Except', () => {
imports: [NgxPermissionsModule.forRoot()]
});
});
beforeEach(inject([NgxPermissionsService, NgxRolesService], (service: NgxPermissionsService, rolesService: NgxRolesService) => {
beforeEach(inject([NgxPermissionsService, NgxRolesService, NgxPermissionsConfigurationService], (service: NgxPermissionsService, rolesService: NgxRolesService, configurationService: NgxPermissionsConfigurationService) => {
fakeRouter = {
navigate: () => {
}
} as any;
spyOn(fakeRouter, 'navigate');

service.addPermission('MANAGER');
permissionGuard = new NgxPermissionsGuard(service, rolesService, fakeRouter as Router);
permissionGuard = new NgxPermissionsGuard(service, rolesService, fakeRouter as Router, configurationService);
}));

it('should create an instance', () => {
Expand Down Expand Up @@ -234,15 +234,15 @@ describe('Permissions guard Except and only together', () => {
imports: [NgxPermissionsModule.forRoot()]
});
});
beforeEach(inject([NgxPermissionsService, NgxRolesService], (service: NgxPermissionsService, rolesService: NgxRolesService) => {
beforeEach(inject([NgxPermissionsService, NgxRolesService, NgxPermissionsConfigurationService], (service: NgxPermissionsService, rolesService: NgxRolesService, configurationService: NgxPermissionsConfigurationService) => {
fakeRouter = {
navigate: () => {
}
} as any;
spyOn(fakeRouter, 'navigate');

service.addPermission('MANAGER');
permissionGuard = new NgxPermissionsGuard(service, rolesService, fakeRouter as Router);
permissionGuard = new NgxPermissionsGuard(service, rolesService, fakeRouter as Router, configurationService);
}));

it('should create an instance', () => {
Expand Down Expand Up @@ -351,8 +351,8 @@ describe('Permissions guard use only dynamically', () => {
});
});
beforeEach(inject(
[NgxPermissionsService, NgxRolesService],
(service: NgxPermissionsService, rolesService: NgxRolesService, router: Router) => {
[NgxPermissionsService, NgxRolesService, NgxPermissionsConfigurationService],
(service: NgxPermissionsService, rolesService: NgxRolesService, configurationService: NgxPermissionsConfigurationService, router: Router) => {
fakeRouter = {
navigate: () => {
}
Expand All @@ -361,7 +361,7 @@ describe('Permissions guard use only dynamically', () => {
service.addPermission('MANAGER');
// fakeRouter = router;
spyOn(fakeRouter, 'navigate');
permissionGuard = new NgxPermissionsGuard(service, rolesService, fakeRouter as Router);
permissionGuard = new NgxPermissionsGuard(service, rolesService, fakeRouter as Router, configurationService);
}));

it('should create an instance', () => {
Expand Down Expand Up @@ -498,8 +498,8 @@ describe('Permissions guard test redirectTo path parameters dynamically', () =>
});
});
beforeEach(inject(
[NgxPermissionsService, NgxRolesService],
(service: NgxPermissionsService, rolesService: NgxRolesService, router: Router) => {
[NgxPermissionsService, NgxRolesService, NgxPermissionsConfigurationService],
(service: NgxPermissionsService, rolesService: NgxRolesService, configurationService: NgxPermissionsConfigurationService, router: Router) => {
fakeRouter = {
navigate: () => {
}
Expand All @@ -508,7 +508,7 @@ describe('Permissions guard test redirectTo path parameters dynamically', () =>
service.addPermission('MANAGER');
// fakeRouter = router;
spyOn(fakeRouter, 'navigate');
permissionGuard = new NgxPermissionsGuard(service, rolesService, fakeRouter as Router);
permissionGuard = new NgxPermissionsGuard(service, rolesService, fakeRouter as Router, configurationService);
}));

it('should create an instance', () => {
Expand Down Expand Up @@ -603,7 +603,7 @@ describe('Permissions guard test redirectTo path multiple redirectionRule', () =
imports: [NgxPermissionsModule.forRoot()]
});
});
beforeEach(inject([NgxPermissionsService, NgxRolesService], (service: NgxPermissionsService, rolesService: NgxRolesService) => {
beforeEach(inject([NgxPermissionsService, NgxRolesService, NgxPermissionsConfigurationService], (service: NgxPermissionsService, rolesService: NgxRolesService, configurationService: NgxPermissionsConfigurationService) => {
fakeRouter = {
navigate: () => {
}
Expand All @@ -613,7 +613,7 @@ describe('Permissions guard test redirectTo path multiple redirectionRule', () =
fakeService = service;
// fakeRouter = router;
spyOn(fakeRouter, 'navigate');
permissionGuard = new NgxPermissionsGuard(service, rolesService, fakeRouter as Router);
permissionGuard = new NgxPermissionsGuard(service, rolesService, fakeRouter as Router, configurationService);
}));

it('should create an instance', () => {
Expand Down Expand Up @@ -904,7 +904,7 @@ describe('Permissions guard test redirectTo path multiple redirectionRule permis
imports: [NgxPermissionsModule.forRoot()]
});
});
beforeEach(inject([NgxPermissionsService, NgxRolesService], (service: NgxPermissionsService, rolesService: NgxRolesService) => {
beforeEach(inject([NgxPermissionsService, NgxRolesService, NgxPermissionsConfigurationService], (service: NgxPermissionsService, rolesService: NgxRolesService, configurationService: NgxPermissionsConfigurationService) => {
fakeRouter = {
navigate: () => {
}
Expand All @@ -914,7 +914,7 @@ describe('Permissions guard test redirectTo path multiple redirectionRule permis
fakeService = service;
// fakeRouter = router;
spyOn(fakeRouter, 'navigate');
permissionGuard = new NgxPermissionsGuard(service, rolesService, fakeRouter as Router);
permissionGuard = new NgxPermissionsGuard(service, rolesService, fakeRouter as Router, configurationService);
}));

it('should create an instance', () => {
Expand Down Expand Up @@ -1088,7 +1088,7 @@ describe('Permissions guard test redirectTo path dynamic redirectionRule permiss
imports: [NgxPermissionsModule.forRoot()]
});
});
beforeEach(inject([NgxPermissionsService, NgxRolesService], (service: NgxPermissionsService, rolesService: NgxRolesService) => {
beforeEach(inject([NgxPermissionsService, NgxRolesService, NgxPermissionsConfigurationService], (service: NgxPermissionsService, rolesService: NgxRolesService, configurationService: NgxPermissionsConfigurationService) => {
fakeRouter = {
navigate: () => {
}
Expand All @@ -1098,7 +1098,7 @@ describe('Permissions guard test redirectTo path dynamic redirectionRule permiss
fakeService = service;
// fakeRouter = router;
spyOn(fakeRouter, 'navigate');
permissionGuard = new NgxPermissionsGuard(service, rolesService, fakeRouter as Router);
permissionGuard = new NgxPermissionsGuard(service, rolesService, fakeRouter as Router, configurationService);
}));

it('should create an instance', () => {
Expand Down Expand Up @@ -1319,7 +1319,7 @@ describe('Permissions guard test redirectTo as function', () => {
imports: [NgxPermissionsModule.forRoot()]
});
});
beforeEach(inject([NgxPermissionsService, NgxRolesService], (service: NgxPermissionsService, rolesService: NgxRolesService) => {
beforeEach(inject([NgxPermissionsService, NgxRolesService, NgxPermissionsConfigurationService], (service: NgxPermissionsService, rolesService: NgxRolesService, configurationService: NgxPermissionsConfigurationService) => {
fakeRouter = {
navigate: () => {
}
Expand All @@ -1329,7 +1329,7 @@ describe('Permissions guard test redirectTo as function', () => {
fakeService = service;
// fakeRouter = router;
spyOn(fakeRouter, 'navigate');
permissionGuard = new NgxPermissionsGuard(service, rolesService, fakeRouter as Router);
permissionGuard = new NgxPermissionsGuard(service, rolesService, fakeRouter as Router, configurationService);
}));

it('should create an instance', () => {
Expand Down
Loading