Skip to content

Commit

Permalink
fix(a15): adding NG_MOCKS_ROOT_PROVIDERS for RouteReuseStrategy
Browse files Browse the repository at this point in the history
  • Loading branch information
satanTime committed Nov 26, 2022
1 parent 83fd242 commit 737247d
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 8 deletions.
9 changes: 8 additions & 1 deletion docs/articles/guides/route.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@ import { fakeAsync, tick } from '@angular/core/testing';
import { Router, RouterModule, RouterOutlet } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';

import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';
import {
MockBuilder,
MockRender,
NG_MOCKS_ROOT_PROVIDERS,
ngMocks,
} from 'ng-mocks';

// A layout component that renders the current route.
@Component({
Expand Down Expand Up @@ -181,6 +186,7 @@ describe('TestRoute:Route', () => {
[
RouterModule,
RouterTestingModule.withRoutes([]),
NG_MOCKS_ROOT_PROVIDERS,
],
TargetModule,
);
Expand Down Expand Up @@ -237,6 +243,7 @@ describe('TestRoute:Component', () => {
TargetComponent,
RouterModule,
RouterTestingModule.withRoutes([]),
NG_MOCKS_ROOT_PROVIDERS,
],
TargetModule,
);
Expand Down
2 changes: 2 additions & 0 deletions docs/articles/guides/routing-guard.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import {
MockBuilder,
MockRender,
NG_MOCKS_GUARDS,
NG_MOCKS_ROOT_PROVIDERS,
ngMocks,
} from 'ng-mocks';

Expand Down Expand Up @@ -170,6 +171,7 @@ describe('TestRoutingGuard', () => {
LoginGuard,
RouterModule,
RouterTestingModule.withRoutes([]),
NG_MOCKS_ROOT_PROVIDERS,
],
TargetModule,
).exclude(NG_MOCKS_GUARDS);
Expand Down
8 changes: 7 additions & 1 deletion docs/articles/guides/routing-resolver.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ import { RouterTestingModule } from '@angular/router/testing';
import { combineLatest, from, Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';

import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';
import {
MockBuilder,
MockRender,
NG_MOCKS_ROOT_PROVIDERS,
ngMocks,
} from 'ng-mocks';

// A simple service simulating a data request.
@Injectable()
Expand Down Expand Up @@ -167,6 +172,7 @@ describe('TestRoutingResolver', () => {
DataResolver,
RouterModule,
RouterTestingModule.withRoutes([]),
NG_MOCKS_ROOT_PROVIDERS,
],
TargetModule,
);
Expand Down
14 changes: 12 additions & 2 deletions examples/TestRoute/test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import { fakeAsync, tick } from '@angular/core/testing';
import { Router, RouterModule, RouterOutlet } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';

import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';
import {
MockBuilder,
MockRender,
NG_MOCKS_ROOT_PROVIDERS,
ngMocks,
} from 'ng-mocks';

// A layout component that renders the current route.
@Component({
Expand Down Expand Up @@ -61,7 +66,11 @@ class TargetModule {}
describe('TestRoute:Route', () => {
beforeEach(() => {
return MockBuilder(
[RouterModule, RouterTestingModule.withRoutes([])],
[
RouterModule,
RouterTestingModule.withRoutes([]),
NG_MOCKS_ROOT_PROVIDERS,
],
TargetModule,
);
});
Expand Down Expand Up @@ -117,6 +126,7 @@ describe('TestRoute:Component', () => {
TargetComponent,
RouterModule,
RouterTestingModule.withRoutes([]),
NG_MOCKS_ROOT_PROVIDERS,
],
TargetModule,
);
Expand Down
8 changes: 7 additions & 1 deletion examples/TestRoutingGuard/test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
MockBuilder,
MockRender,
NG_MOCKS_GUARDS,
NG_MOCKS_ROOT_PROVIDERS,
ngMocks,
} from 'ng-mocks';

Expand Down Expand Up @@ -116,7 +117,12 @@ describe('TestRoutingGuard', () => {
// `NG_MOCKS_GUARDS` to remove all other guards.
beforeEach(() => {
return MockBuilder(
[LoginGuard, RouterModule, RouterTestingModule.withRoutes([])],
[
LoginGuard,
RouterModule,
RouterTestingModule.withRoutes([]),
NG_MOCKS_ROOT_PROVIDERS,
],
TargetModule,
).exclude(NG_MOCKS_GUARDS);
});
Expand Down
8 changes: 7 additions & 1 deletion examples/TestRoutingResolver/test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ import { RouterTestingModule } from '@angular/router/testing';
import { combineLatest, from, Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';

import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';
import {
MockBuilder,
MockRender,
NG_MOCKS_ROOT_PROVIDERS,
ngMocks,
} from 'ng-mocks';

// A simple service simulating a data request.
@Injectable()
Expand Down Expand Up @@ -93,6 +98,7 @@ describe('TestRoutingResolver', () => {
DataResolver,
RouterModule,
RouterTestingModule.withRoutes([]),
NG_MOCKS_ROOT_PROVIDERS,
],
TargetModule,
);
Expand Down
14 changes: 12 additions & 2 deletions tests/issue-151/test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Router, RouterModule } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';

import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';
import {
MockBuilder,
MockRender,
NG_MOCKS_ROOT_PROVIDERS,
ngMocks,
} from 'ng-mocks';

import { AppComponent } from './app/app.component';
import { AppModule } from './app/app.module';
Expand All @@ -15,7 +20,12 @@ describe('issue-151', () => {
beforeEach(() =>
TestBed.configureTestingModule(
MockBuilder(
[AppComponent, RouterModule, RouterTestingModule],
[
AppComponent,
RouterModule,
RouterTestingModule,
NG_MOCKS_ROOT_PROVIDERS,
],
AppModule,
).build(),
),
Expand Down

0 comments on commit 737247d

Please sign in to comment.