How to use the @angular/router.NavigationEnd 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 Greentube / localize-router / tests / localize-router.service.spec.ts View on Github external
it('should not translate routes if not NavigationStart', () => {
    localizeRouterService = new LocalizeRouterService(loader, router);
    loader.currentLang = 'de';
    loader.locales = ['de', 'en'];
    spyOn(loader, 'translateRoutes').and.stub();

    (router as FakeRouter).fakeRouterEvents.next(new NavigationEnd(1, '/en/new/path', '/en/new/path'));
    expect(loader.translateRoutes).not.toHaveBeenCalled();
  });
github dancancro / great-big-example-application / src / main / webapp / app / features / meals / shared / ax-focus-fix / ax-focus-fix.directive.spec.ts View on Github external
it('should skip non-home routes', () => {
        let testEvent: NavigationEnd;
        testEvent = new NavigationEnd(1, '/test', '/test');
        mockRouter.fakeEvent(testEvent);
        expect(component.axFocus01Fix.skipRoute).toBe(true);
        testEvent = new NavigationEnd(1, '/', '/');
        mockRouter.fakeEvent(testEvent);
        expect(component.axFocus01Fix.skipRoute).toBe(false);
    });
github accordproject / concerto / packages / composer-playground / src / app / login / login.component.spec.ts View on Github external
set eventParams(event) {
        let nav;
        if (event.nav === 'end') {
            console.log('MY ONLY FRIEND THE END');
            nav = new NavigationEnd(0, event.url, event.urlAfterRedirects);
        } else {
            nav = new NavigationStart(0, event.url);
        }
        this._eventParams = nav;
        this.subject.next(nav);
    }
github ProgrammeVitam / vitam / sources / ihm-demo / ihm-demo-front / src / app / archive-unit / archive-unit-details / archive-unit-details.component.spec.ts View on Github external
it('should reinit page when archiveUnitDetail is called', (done) => {
    spyOn(component, 'pageOnInit').and.callFake(() => {
      done();
    });
    spyOn(component.router, 'events').and.returnValues(
      Observable.of(new NavigationEnd(1, 'search/archiveUnit/myId', 'urlAfterRedirect'))
    );
    component.router.navigateByUrl('search/archiveUnit/myId');
  });
github Sunbird-Ed / SunbirdEd-portal / src / app / client / projects / desktop / src / app / app.component.spec.ts View on Github external
import { TestBed, async, ComponentFixture, fakeAsync, tick } from '@angular/core/testing';
import { mockData } from './app.component.spec.data';
import { AppComponent } from './app.component';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { RouterTestingModule } from '@angular/router/testing';
import * as _ from 'lodash-es';
import { ProfileService } from '@sunbird/profile';
import { CacheService } from 'ng2-cache-service';
import { animate, AnimationBuilder, AnimationMetadata, AnimationPlayer, style } from '@angular/animations';

import { Router, NavigationEnd, ActivatedRoute } from '@angular/router';
import { OnboardingService } from './modules/offline';

class RouterStub {
  public navigationEnd = new NavigationEnd(0, '/explore', '/explore');
  public navigate = jasmine.createSpy('navigate');
  public url = '';
  public events = new Observable(observer => {
    observer.next(this.navigationEnd);
    observer.complete();
  });
}
const fakeActivatedRoute = {
  snapshot: {
    root: { firstChild: { params: { slug: 'sunbird' } } }
  },
  queryParams: of({})
};


describe('AppComponent', () => {
github SAP / cloud-commerce-spartacus-storefront / projects / cds / src / profiletag / services / profiletag-events.spec.ts View on Github external
and event receiver callback has been called with loaded`, () => {
    let timesCalled = 0;
    const subscription = profileTagEventTracker
      .profileTagLoaded()
      .pipe(tap(_ => timesCalled++))
      .subscribe();
    getActiveBehavior.next('electronics-test');
    eventListener(new CustomEvent(ProfileTagEventNames.LOADED));
    routerEventsBehavior.next(new NavigationEnd(0, 'test', 'test'));
    subscription.unsubscribe();

    expect(timesCalled).toEqual(1);
  });
github dotCMS / core-web / src / app / view / components / dot-navigation / dot-navigation.component.spec.ts View on Github external
triggerOnNavigationEnd(url?: string) {
        return this._routeEvents.next(new NavigationEnd(0, url || '/url/789', url || '/url/789'));
    }
github project-flogo / flogo-web / src / client / app / flow / triggers / triggers.component.spec.ts View on Github external
events = Observable.create(observer => {
    observer.next(new NavigationEnd(123, '', ''));
    observer.complete();
  });
}
github SAP / cloud-commerce-spartacus-storefront / projects / cds / src / profiletag / services / profile-tag.injector.spec.ts View on Github external
const profileTagLoaded$ = profileTagInjector.track();
    const subscription = profileTagLoaded$.subscribe();
    getActiveBehavior.next('electronics-test');
    nativeWindow.Y_TRACKING.q[0][0].profileTagEventReceiver({
      name: 'Loaded',
    });
    isConsentGivenValue = true;
    getConsentBehavior.next({ consent: 'test' });
    isConsentGivenValue = false;
    getConsentBehavior.next({ consent: 'test' });
    isConsentGivenValue = true;
    getConsentBehavior.next({ consent: 'test' });
    routerEventsBehavior.next(new NavigationEnd(0, 'test', 'test'));
    routerEventsBehavior.next(new NavigationEnd(0, 'test', 'test'));
    routerEventsBehavior.next(new NavigationEnd(0, 'test', 'test2'));
    routerEventsBehavior.next(new NavigationEnd(0, 'test', 'test3'));
    routerEventsBehavior.next(new NavigationEnd(0, 'test', 'test1'));
    subscription.unsubscribe();
    expect(nativeWindow.Y_TRACKING.push).toHaveBeenCalledTimes(6);
    expect(nativeWindow.Y_TRACKING.push).toHaveBeenCalledWith({
      event: 'Navigated',
    });
  });
github SAP / cloud-commerce-spartacus-storefront / projects / cds / src / profiletag / services / profile-tag.injector.spec.ts View on Github external
const subscription = profileTagLoaded$.subscribe();
    getActiveBehavior.next('electronics-test');
    nativeWindow.Y_TRACKING.q[0][0].profileTagEventReceiver({
      name: 'Loaded',
    });
    isConsentGivenValue = true;
    getConsentBehavior.next({ consent: 'test' });
    isConsentGivenValue = false;
    getConsentBehavior.next({ consent: 'test' });
    isConsentGivenValue = true;
    getConsentBehavior.next({ consent: 'test' });
    routerEventsBehavior.next(new NavigationEnd(0, 'test', 'test'));
    routerEventsBehavior.next(new NavigationEnd(0, 'test', 'test'));
    routerEventsBehavior.next(new NavigationEnd(0, 'test', 'test2'));
    routerEventsBehavior.next(new NavigationEnd(0, 'test', 'test3'));
    routerEventsBehavior.next(new NavigationEnd(0, 'test', 'test1'));
    subscription.unsubscribe();
    expect(nativeWindow.Y_TRACKING.push).toHaveBeenCalledTimes(6);
    expect(nativeWindow.Y_TRACKING.push).toHaveBeenCalledWith({
      event: 'Navigated',
    });
  });