How to use the @angular/router.UrlSegment 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 FINRAOS / herd-ui / src / app / core / services / custom-route-reuse-strategy.service.spec.ts View on Github external
it('should properly process retrieval of stored  Route Handles', () => {
        const strat = new CustomRouteReuseStrategy();
        const testConfig2: ActivatedRouteSnapshot = {
            url: [new UrlSegment('test', {})]
        } as ActivatedRouteSnapshot;

        const testConfig: ActivatedRouteSnapshot = {
            pathFromRoot: [{}, testConfig2, {}, {}, {
                url: [new UrlSegment('url', { 'id': '1' })]
            }]
        } as ActivatedRouteSnapshot;

        // due to no route config
        expect(strat.retrieve(testConfig)).toBe(null);
        (testConfig as any).routeConfig = {
            path: 'url'
        };
        // due to not existing in storage
        expect(strat.retrieve(testConfig)).toBe(null);

        (testConfig as any).routeConfig.loadChildren = 'fakeLoadchildren#module.module';
        // due to having load children. these should never be stored.
        expect(strat.retrieve(testConfig)).toBe(null);

        delete (testConfig as any).routeConfig.loadChildren;
github DSpace / dspace-angular / src / app / +lookup-by-id / lookup-by-id-routing.module.ts View on Github external
export function urlMatcher(url) {
  // The expected path is :idType/:id
  const idType = url[0].path;
  // Allow for handles that are delimited with a forward slash.
  const id = url
    .slice(1)
    .map((us: UrlSegment) => us.path)
    .join('/');
  if (isNotEmpty(idType) && isNotEmpty(id)) {
    return {
      consumed: url,
      posParams: {
        idType: new UrlSegment(idType, {}),
        id: new UrlSegment(id, {})
      }
    };
  }
  return null;
}
github DSpace / dspace-angular / src / app / +lookup-by-id / lookup-by-id-routing.module.ts View on Github external
export function urlMatcher(url) {
  // The expected path is :idType/:id
  const idType = url[0].path;
  // Allow for handles that are delimited with a forward slash.
  const id = url
    .slice(1)
    .map((us: UrlSegment) => us.path)
    .join('/');
  if (isNotEmpty(idType) && isNotEmpty(id)) {
    return {
      consumed: url,
      posParams: {
        idType: new UrlSegment(idType, {}),
        id: new UrlSegment(id, {})
      }
    };
  }
  return null;
}
github dotCMS / core-web / src / app / portlets / content-types / create / content-types-create.component.spec.ts View on Github external
it('should have call content types endpoint with widget data', () => {
        url = [
            new UrlSegment('create', { name: 'create' }),
            new UrlSegment('widget', { name: 'widget' })
        ];

        route.url = Observable.of(url);

        const mockData = [
            {
                clazz: 'com.dotcms.contenttype.model.type.ImmutableSimpleContentType',
                defaultType: false,
                fixed: false,
                folder: 'SYSTEM_FOLDER',
                host: '12345',
                id: '1',
                name: 'Hello World',
                owner: '123',
                system: false
            }
github dotCMS / core-web / src / app / portlets / content-types / create-edit / content-types-form / content-types-form.component.spec.ts View on Github external
it('should not send form with invalid data', () => {
        let url = [
            new UrlSegment('create', { name: 'create' }),
            new UrlSegment('content', { name: 'content' })
        ];
        route.url = Observable.of(url);

        fixture.detectChanges();

        let crudService = fixture.debugElement.injector.get(CrudService);
        spyOn(crudService, 'postData').and.returnValue(Observable.of({}));

        let mockData: ContentType = {
            clazz: 'com.dotcms.contenttype.model.type.ImmutableSimpleContentType',
            defaultType: false,
            description: '',
            detailPage: '',
            fixed: false,
            folder: 'SYSTEM_FOLDER',
github shuhei / babel-angular2-app / src / app.spec.js View on Github external
it('renders greeting', () => {
    const params = { name: 'Babel' };
    const url = [new UrlSegment('ciao', params)];
    const route = new ActivatedRoute(Observable.of(url), Observable.of(params));
    TestBed.configureTestingModule({
      declarations: [Ciao],
      providers: [Greeter, { provide: ActivatedRoute, useValue: route }],
    });

    const fixture = TestBed.createComponent(Ciao);
    fixture.detectChanges();

    expect(fixture.debugElement.nativeElement.textContent).toEqual('Ciao, Babel!');
  });
});
github adobe / aem-project-archetype / src / main / archetype / ui.frontend.angular / src / app / app-routing.module.spec.ts View on Github external
it('should return matcher if path starts with app path root', () => {
    var a = new UrlSegment('content', {});
    var b = new UrlSegment('we-retail-journal', {});
    var c = new UrlSegment('angular', {});
    var d = new UrlSegment('foo.html', {});
    var url = [a, b, c, d];

    expect(AemPageMatcher(url)).toEqual({
      consumed: url,
      posParams: {
        path: d
      }
    });
  });
});
github adobe / aem-project-archetype / src / main / archetype / ui.frontend.angular / src / app / app-routing.module.spec.ts View on Github external
it('should return matcher if path starts with app path root', () => {
    var a = new UrlSegment('content', {});
    var b = new UrlSegment('we-retail-journal', {});
    var c = new UrlSegment('angular', {});
    var d = new UrlSegment('foo.html', {});
    var url = [a, b, c, d];

    expect(AemPageMatcher(url)).toEqual({
      consumed: url,
      posParams: {
        path: d
      }
    });
  });
});
github alvachien / acgallery / src / app / photochange / photochange.component.spec.ts View on Github external
beforeEach(async(() => {
    const routerSpy: any = jasmine.createSpyObj('Router', ['navigate']);
    const activatedRouteStub: any = new ActivatedRouteUrlStub([new UrlSegment('createbrwfrm', {})] as UrlSegment[]);
    const authServiceStub: Partial = {};
    authServiceStub.authSubject = new BehaviorSubject(new UserAuthInfo());
    const photoService: any = jasmine.createSpyObj('PhotoService', ['loadAlbumPhoto']);
    const loadAlbumPhotoSpy: any = photoService.loadAlbumPhoto.and.returnValue(of([]));
    const albumService: any = jasmine.createSpyObj('AlbumService', ['loadAlbums', 'loadAlbumContainsPhoto']);
    const loadAlbumsSpy: any = albumService.loadAlbums.and.returnValue(of([]));
    const loadAlbumContainsPhotoSpy: any = albumService.loadAlbumContainsPhoto.and.returnValue(of([]));

    TestBed.configureTestingModule({
      imports: [
        MatFormFieldModule,
        MatCardModule,
        FormsModule,
        MatCheckboxModule,
        MatChipsModule,
        MatIconModule,
github alvachien / acgallery / src / app / album / album.component.spec.ts View on Github external
beforeEach(async(() => {
    const routerSpy: any = jasmine.createSpyObj('Router', ['navigate']);
    const activatedRouteStub: any = new ActivatedRouteUrlStub([new UrlSegment('create', {})] as UrlSegment[]);
    const albumService: any = jasmine.createSpyObj('AlbumService', ['loadAlbum']);
    const loadAlbumSpy: any = albumService.loadAlbum.and.returnValue(of([]));
    const photoService: any = jasmine.createSpyObj('PhotoService', ['loadAlbumPhoto']);
    const loadAlbumPhotoSpy: any = photoService.loadAlbumPhoto.and.returnValue(of([]));

    TestBed.configureTestingModule({
      imports: [
        MatGridListModule,
        MatExpansionModule,
        MatDividerModule,
        MatButtonModule,
        MatMenuModule,
        MatIconModule,
        MatPaginatorModule,
        MatSnackBarModule,
        MatDialogModule,