-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4a5926
commit 52bbf09
Showing
6 changed files
with
70 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
<h2>{{title}}</h2> | ||
<div *ngFor="let employee of employees"> | ||
{{employee.id}} - {{employee.name}} - {{employee.role.name}} | ||
<div id="employee-list"> | ||
<div *ngFor="let employee of employees"> | ||
{{employee.id}} - {{employee.name}} - {{employee.role.name}} | ||
</div> | ||
</div> |
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,9 @@ | ||
import { EmployeeComponent } from './../employee/employee.component'; | ||
import { HomeComponent } from './../home/home.component'; | ||
import { Routes } from '@angular/router'; | ||
|
||
export const routes: Routes = [ | ||
{ path: '', redirectTo: 'home', pathMatch: 'full' }, | ||
{ path: 'home', component: HomeComponent }, | ||
{ path: 'employee/:role', component: EmployeeComponent } | ||
]; |
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,54 @@ | ||
import { routes } from './../app/routes/routes'; | ||
import { EmployeeComponent } from './../app/employee/employee.component'; | ||
import { HomeComponent } from './../app/home/home.component'; | ||
import { AppComponent } from './../app/app.component'; | ||
import { Router } from '@angular/router'; | ||
import { By } from '@angular/platform-browser'; | ||
import { AppStateServiceMock } from './mocks/app-state.service.mock'; | ||
import { AppStateService } from './../app/app-status/app-state.service'; | ||
import { ComponentFixture, TestBed, async } from '@angular/core/testing'; | ||
import { DebugElement } from '@angular/core'; | ||
import { RouterTestingModule } from "@angular/router/testing"; | ||
import { fakeAsync } from "@angular/core/testing"; | ||
import { tick } from "@angular/core/testing"; | ||
import { AlertModule } from 'ngx-bootstrap/alert'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { Location } from "@angular/common"; | ||
|
||
describe('Navigation',() => { | ||
let location: Location; | ||
let router: Router; | ||
let fixture; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
AlertModule, | ||
RouterTestingModule.withRoutes(routes), | ||
FormsModule | ||
], | ||
declarations: [ AppComponent, HomeComponent, EmployeeComponent ], | ||
providers: [ | ||
{ provide: AppStateService, useClass: AppStateServiceMock }, | ||
] | ||
}); | ||
router = TestBed.get(Router); | ||
location = TestBed.get(Location); | ||
fixture = TestBed.createComponent(AppComponent); | ||
router.initialNavigation(); | ||
}); | ||
|
||
it('navigate to "" redirects you to /home', fakeAsync(() => { | ||
router.navigate(['']).then(() => { | ||
expect(location.path()).toBe('/home'); | ||
}); | ||
tick(); | ||
})); | ||
|
||
it('navigate to "employee/3" takes you to employee/3', fakeAsync(() => { | ||
router.navigate(['/employee/3']).then(() => { | ||
expect(location.path()).toBe('/employee/3'); | ||
}); | ||
tick(); | ||
})); | ||
}); |