Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const routing = () => {
return routes ? [RouterTestingModule.withRoutes(routes)] : [];
};
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule.withRoutes([
{ path: '', component: FakeComponent },
{ path: 'foo', component: FakeComponent },
]),
],
declarations: [FakeComponent],
providers: [RouterPathService],
});
TestBed.compileComponents();
}));
authorizedHandler: () => {
AUTH_HANDLER = true;
},
unauthorizedHandler: () => {
UNAUTH_HANDLER = true;
}
}
},
component: TestSecuredComponent
}
];
@NgModule({
imports: [
TestSecuredModule,
RouterTestingModule.withRoutes(routes)
]
})
export class TestSecuredRouterModule {}
describe('NgxSecurityGuard', () => {
let router: Router;
let location: Location;
let component: TestSecuredComponent;
let fixture: ComponentFixture;
let security: NgxSecurityService;
beforeEach(() => {
AUTH_HANDLER = false;
UNAUTH_HANDLER = false;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [AppModule, RouterTestingModule.withRoutes([])],
providers: [ProvidedService, MockBackend, BaseRequestOptions,
{
provide: Http,
useFactory: (mockBackend: MockBackend, defaultOptions: RequestOptions) => {
return new Http(mockBackend, defaultOptions);
},
useClass: Http,
deps: [MockBackend, BaseRequestOptions]
}
]
}).compileComponents();
}));
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
FormsModule,
ReactiveFormsModule,
MatIconModule,
MatToolbarModule,
MatMenuModule,
MatCheckboxModule,
CommonModule,
NoopAnimationsModule,
RouterTestingModule.withRoutes([{path: 'server/1/preferences/builtin/ethernet-switches', component: EthernetSwitchesAddTemplateComponent}])
],
providers: [
{
provide: ActivatedRoute, useValue: activatedRoute
},
{ provide: ServerService, useValue: mockedServerService },
{ provide: BuiltInTemplatesService, useValue: mockedBuiltInTemplatesService },
{ provide: ToasterService, useValue: mockedToasterService},
{ provide: TemplateMocksService, useClass: TemplateMocksService }
],
declarations: [
EthernetSwitchesAddTemplateComponent
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();
}));
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [TestComponent],
imports: [
StoreModule.forRoot(fromReducer.reducerToken),
RouterTestingModule.withRoutes([
{ path: '', component: TestComponent },
{ path: 'category/:categoryCode', component: TestComponent },
{ path: 'product/:productCode', component: TestComponent },
{
path: 'cmsPage',
component: TestComponent,
data: { pageLabel: 'testPageLabel' },
},
{
path: 'dynamically-created',
component: TestComponent,
children: [{ path: 'sub-route', component: TestComponent }],
data: {
cxCmsRouteContext: {
type: PageType.CONTENT_PAGE,
id: 'explicit',
VariableService,
NavbarService,
PipelineService,
{ provide: ActivatedRoute, useClass: MockActivatedRoutes },
{ provide: Router, useClass: MockRouter },
EnvironmentService,
WorkflowService,
WorkflowRunService
],
imports: [
ProjectModule,
SharedModule,
NgxsStoreModule,
TranslateModule.forRoot(),
ServicesModule,
RouterTestingModule.withRoutes([
{ path: 'project/:key', component: ProjectEnvironmentListComponent },
]),
HttpClientTestingModule
]
});
this.injector = getTestBed();
});
async(() => {
TestBed.configureTestingModule({
imports: [
SyndesisCommonModule.forRoot(),
StoreModule,
RouterTestingModule.withRoutes([]),
RestangularModule.forRoot(),
ModalModule.forRoot(),
TooltipModule.forRoot(),
TabsModule.forRoot(),
NotificationModule,
PatternflyUIModule,
IntegrationsListModule
],
declarations: [IntegrationsListPage],
providers: [
MockBackend,
{ provide: RequestOptions, useClass: BaseRequestOptions },
{
provide: Http,
useFactory: (backend, options) => {
return new Http(backend, options);
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
FormsModule,
ReactiveFormsModule,
MatIconModule,
MatToolbarModule,
MatMenuModule,
MatCheckboxModule,
CommonModule,
NoopAnimationsModule,
RouterTestingModule.withRoutes([{path: 'server/1/preferences/builtin/cloud-nodes', component: CloudNodesAddTemplateComponent}])
],
providers: [
{ provide: ActivatedRoute, useValue: activatedRoute },
{ provide: ServerService, useValue: mockedServerService },
{ provide: BuiltInTemplatesService, useValue: mockedBuiltInTemplatesService },
{ provide: ToasterService, useValue: mockedToasterService },
{ provide: TemplateMocksService, useClass: TemplateMocksService }
],
declarations: [
CloudNodesAddTemplateComponent
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();
}));