Skip to content

docs(aio): Testing: Description and code don't match #16064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
andys8 opened this issue Apr 17, 2017 · 3 comments
Closed

docs(aio): Testing: Description and code don't match #16064

andys8 opened this issue Apr 17, 2017 · 3 comments

Comments

@andys8
Copy link
Contributor

andys8 commented Apr 17, 2017

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior
The code example is a single line using subscribe:

this.route.params.subscribe(p => this.getHero(p && p['id']));

The description talks about the usage of pluck and forEach. They aren't used (probably anymore) in the code. This is misleading.

The expression after route.params chains an Observable operator that plucks the id from the params and then chains a forEach operator to subscribe to id-changing events. The id changes every time the user navigates to a different hero.
The forEach passes the new id value to the component's getHero method (not shown) which fetches a hero and sets the component's hero property. If the id parameter is missing, the pluck operator fails and the catch treats failure as a request to edit a new hero.

Screenshot

image

Expected behavior
The description should match the code. The description should be replaced or removed.

Affected Files
https://github.com/angular/angular/blob/master/aio/content/examples/testing/src/app/hero/hero-detail.component.ts
https://raw.githubusercontent.com/angular/angular/master/aio/content/guide/testing.md

@kapunahelewong
Copy link
Contributor

@jenniferfell This issue might be resolved in #20697.

@ngbot ngbot bot added this to the needsTriage milestone Feb 28, 2018
@jenniferfell
Copy link
Contributor

Closing. Doc and example were updated at some point to use paramMap.subscribe instead of the code above:

ngOnInit(): void {
// get hero when id param changes
this.route.paramMap.subscribe(pmap => this.getHero(pmap.get('id')));
}

filename=https://angular.io/guide/testing

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants