Skip to content

Commit

Permalink
fix: router test
Browse files Browse the repository at this point in the history
Fixes a test that seems to be affected by the decorator emission after the upgrade
  • Loading branch information
nerumo committed Dec 9, 2022
1 parent f62ea6c commit 237359a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
5 changes: 3 additions & 2 deletions packages/ng-router-store/src/lib/router.query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { filterNilValue, Query } from '@datorama/akita';
import { combineLatest, Observable, Subject } from 'rxjs';
import { distinctUntilChanged, map, pluck } from 'rxjs/operators';
import { RouterState, RouterStore } from './router.store';
import {NavigationCancel, NavigationError} from '@angular/router';

function slice(section: string) {
return (source: Observable<RouterState>) => {
Expand All @@ -17,8 +18,8 @@ function slice(section: string) {
providedIn: 'root',
})
export class RouterQuery extends Query<RouterState> {
__navigationCancel = new Subject();
__navigationError = new Subject();
__navigationCancel = new Subject<NavigationCancel>();
__navigationError = new Subject<NavigationError>();

constructor(protected store: RouterStore) {
super(store);
Expand Down
12 changes: 10 additions & 2 deletions packages/ng-router-store/src/lib/router.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { APP_BASE_HREF } from '@angular/common';
import { Component, Injectable, NgZone } from '@angular/core';
import { fakeAsync, TestBed, tick } from '@angular/core/testing';
import { ActivatedRouteSnapshot, CanActivate, NavigationExtras, Router, Routes } from '@angular/router';
import {ActivatedRouteSnapshot, CanActivate, NavigationCancel, NavigationExtras, Router, Routes} from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { AkitaNgRouterStoreModule } from '..';
import { RouterQuery } from './router.query';
Expand Down Expand Up @@ -126,7 +126,15 @@ describe('RouterService', () => {
expect.assertions(3);

routerQuery.selectNavigationCancel().subscribe((event) => {
expect(event).toEqual({ id: 2, reason: 'NavigationCancelingError: Redirecting to "/home"', url: '/redirect-home' });
expect(event).toEqual(
<NavigationCancel>{
id: 2,
code: 0,
type: 2,
reason: 'NavigationCancelingError: Redirecting to "/home"',
url: '/redirect-home'
}
)
});

routerQuery.select().subscribe(({ navigationId, state }) => {
Expand Down
3 changes: 2 additions & 1 deletion packages/ng-router-store/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
"types": ["jest", "node"],
"emitDecoratorMetadata": false // see https://github.com/thymikee/jest-preset-angular/issues/1199
},
"files": ["src/test-setup.ts"],
"include": ["**/*.test.ts", "**/*.spec.ts", "**/*.d.ts", "jest.config.ts"]
Expand Down

0 comments on commit 237359a

Please sign in to comment.