-
-
Notifications
You must be signed in to change notification settings - Fork 176
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
Netanel Basal
committed
May 19, 2020
1 parent
5f94be4
commit 5bed723
Showing
15 changed files
with
174 additions
and
144 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,50 +0,0 @@ | ||
--- | ||
id: integration-testing | ||
title: Integration Testing | ||
--- | ||
|
||
### Integration testing with `RouterTestingModule` | ||
|
||
If you set the `stubsEnabled` option to `false`, you can pass a real routing configuration | ||
and setup an integration test using the `RouterTestingModule` from Angular. | ||
|
||
Note that this requires promises to resolve. One way to deal with this, is by making your test async: | ||
|
||
```ts | ||
describe('Routing integration test', () => { | ||
const createComponent = createRoutingFactory({ | ||
component: MyComponent, | ||
declarations: [OtherComponent], | ||
stubsEnabled: false, | ||
routes: [ | ||
{ | ||
path: '', | ||
component: MyComponent | ||
}, | ||
{ | ||
path: 'foo', | ||
component: OtherComponent | ||
} | ||
] | ||
}); | ||
|
||
it('should navigate away using router link', async () => { | ||
const spectator = createComponent(); | ||
|
||
// wait for promises to resolve... | ||
await spectator.fixture.whenStable(); | ||
|
||
// test the current route by asserting the location | ||
expect(spectator.get(Location).path()).toBe('/'); | ||
|
||
// click on a router link | ||
spectator.click('.link-1'); | ||
|
||
// don't forget to wait for promises to resolve... | ||
await spectator.fixture.whenStable(); | ||
|
||
// test the new route by asserting the location | ||
expect(spectator.get(Location).path()).toBe('/foo'); | ||
}); | ||
}); | ||
``` | ||
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
Oops, something went wrong.