How to use the @angular/router/testing.RouterTestingModule.withRoutes function in @angular/router

To help you get started, we’ve selected a few @angular/router examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github testing-library / angular-testing-library / projects / testing-library / src / lib / testing-library.ts View on Github external
const routing = () => {
    return routes ? [RouterTestingModule.withRoutes(routes)] : [];
  };
github Teradata / covalent / src / platform / core / common / services / router-path.service.spec.ts View on Github external
beforeEach(async(() => {
    TestBed.configureTestingModule({
      imports: [
        RouterTestingModule.withRoutes([
          { path: '', component: FakeComponent },
          { path: 'foo', component: FakeComponent },
        ]),
      ],
      declarations: [FakeComponent],
      providers: [RouterPathService],
    });
    TestBed.compileComponents();
  }));
github mselerin / ngx-security / projects / ngx-security / src / lib / guards / ngx-security.guard.spec.ts View on Github external
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;
github pluralsight-projects / Angular-AlbumStoreProductPage / src / spec / part3 / product-description-html-uses-dynamic-albuminfo-band.projects.spec.ts View on Github external
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();
  }));
github GNS3 / gns3-web-ui / src / app / components / preferences / built-in / ethernet-switches / ethernet-switches-add-template / ethernet-switches-add-template.component.spec.ts View on Github external
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();
    }));
github SAP / cloud-commerce-spartacus-storefront / projects / core / src / routing / store / reducers / router.reducer.spec.ts View on Github external
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',
github ovh / cds / ui / src / app / views / project / show / environment / list / environment.list.spec.ts View on Github external
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();
    });
github syndesisio / syndesis / ui / src / app / integrations / list-page / list-page.component.spec.ts View on Github external
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);
github GNS3 / gns3-web-ui / src / app / components / preferences / built-in / cloud-nodes / cloud-nodes-add-template / cloud-nodes-add-template.component.spec.ts View on Github external
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();
    }));