How to use the @angular/router.RoutesRecognized 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 anihalaney / rwa-trivia / src / app / core / store / effects / question.effects.spec.ts View on Github external
it('load question of the day', () => {
        const completion = new QuestionActions().getQuestionOfTheDaySuccess(question);

        // not sure this best way to emulate it, this can be converted into utility function
        // here to test effect which use router navigation action we are manually mocking it
        // this by pass ngrx route-store and  router all together and only test effect
        const routerState: RouterStateUrl = { url: '/dashboard', queryParams: {}, params: {} };
        const event: RoutesRecognized = new RoutesRecognized(1, '/dashboard', '', null);
        const payload: RouterNavigationPayload = {
            routerState,
            event
        };
        const action: RouterNavigationAction = {
            type: ROUTER_NAVIGATION,
            payload
        };

        actions$ = hot('-a---', { a: action });
        const response = cold('-a|', { a: question });
        const expected = cold('--b', { b: completion });
        questionService.getQuestionOfTheDay = jest.fn(() => {
            console.log('mocked getQuestionOfTheDay');
            return response
        });
github anihalaney / rwa-trivia / projects / trivia / src / app / social / store / effects / social.effects.spec.ts View on Github external
it('get all blogs', () => {
        const obj = TEST_DATA.blog;
        // const action = new LoadBlogs();
        const routerState: RouterStateUrl = { url: '/', queryParams: {}, params: {} };
        const event: RoutesRecognized = new RoutesRecognized(1, '/', '', null);
        const payload: RouterNavigationPayload = {
            routerState,
            event
        };
        const action: RouterNavigationAction = {
            type: ROUTER_NAVIGATION,
            payload
        };
        const completion = new LoadBlogsSuccess(TEST_DATA.blog);
        actions$ = hot('-a----', { a: action });
        const response = cold('-a|', { a: obj });
        const expected = cold('--b', { b: completion });
        socialService.loadBlogs = jest.fn(() => response);

        expect(effects.getBlogs$).toBeObservable(expected);
    });
github ngrx / platform / modules / router-store / src / router_store_module.ts View on Github external
private dispatchRouterNavigation(
    lastRoutesRecognized: RoutesRecognized
  ): void {
    const nextRouterState = this.serializer.serialize(
      lastRoutesRecognized.state
    );
    this.dispatchRouterAction(ROUTER_NAVIGATION, {
      routerState: nextRouterState,
      event: new RoutesRecognized(
        lastRoutesRecognized.id,
        lastRoutesRecognized.url,
        lastRoutesRecognized.urlAfterRedirects,
        nextRouterState
      ),
    });
  }
github ngxs / store / packages / router-plugin / src / router.state.ts View on Github external
private dispatchRouterNavigation(): void {
    const nextRouterState = this._serializer.serialize(this._lastRoutesRecognized.state);

    this.dispatchRouterAction(
      new RouterNavigation(
        nextRouterState,
        new RoutesRecognized(
          this._lastRoutesRecognized.id,
          this._lastRoutesRecognized.url,
          this._lastRoutesRecognized.urlAfterRedirects,
          nextRouterState
        ),
        this._trigger
      )
    );
  }