-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: respect mocks in tokens with useValue
closes #151
- Loading branch information
Showing
12 changed files
with
162 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { RouterModule, Routes } from '@angular/router'; | ||
|
||
import { HelloComponent } from './hello.component'; | ||
import { HelloModule } from './hello.module'; | ||
|
||
const routes: Routes = [ | ||
{ | ||
path: '', | ||
pathMatch: 'full', | ||
redirectTo: '/hello', | ||
}, | ||
{ | ||
component: HelloComponent, | ||
path: 'hello', | ||
}, | ||
]; | ||
|
||
@NgModule({ | ||
exports: [HelloModule, RouterModule], | ||
imports: [HelloModule, RouterModule.forRoot(routes)], | ||
}) | ||
export class AppRoutingModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'my-app', | ||
template: '<router-outlet></router-outlet>', | ||
}) | ||
export class AppComponent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
|
||
import { AppRoutingModule } from './app-routing.module'; | ||
import { AppComponent } from './app.component'; | ||
|
||
@NgModule({ | ||
bootstrap: [AppComponent], | ||
declarations: [AppComponent], | ||
imports: [BrowserModule, AppRoutingModule], | ||
}) | ||
export class AppModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-hello', | ||
template: 'hello', | ||
}) | ||
export class HelloComponent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { NgModule } from '@angular/core'; | ||
|
||
import { HelloComponent } from './hello.component'; | ||
|
||
@NgModule({ | ||
declarations: [HelloComponent], | ||
exports: [HelloComponent], | ||
imports: [CommonModule], | ||
}) | ||
export class HelloModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { Router, RouterModule } from '@angular/router'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { MockBuilder, MockRender } from 'ng-mocks'; | ||
|
||
import { AppComponent } from './app/app.component'; | ||
import { AppModule } from './app/app.module'; | ||
|
||
describe('issue-151', () => { | ||
let fixture: ComponentFixture<AppComponent>; | ||
|
||
describe('mock AppRoutingModule', () => { | ||
beforeEach(() => | ||
TestBed.configureTestingModule( | ||
MockBuilder(AppComponent, AppModule).keep(RouterModule).keep(RouterTestingModule).build() | ||
) | ||
); | ||
|
||
beforeEach(async () => { | ||
fixture = MockRender(AppComponent); | ||
const router = TestBed.get(Router); | ||
if (fixture.ngZone) { | ||
fixture.ngZone.run(() => router.initialNavigation()); | ||
} | ||
await fixture.whenStable(); | ||
}); | ||
|
||
it('should create the app', () => { | ||
// asserting that app-hello is mocked (no content) and detected by router. | ||
expect(fixture.nativeElement.innerHTML).toContain('<app-hello></app-hello>'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters