Skip to content
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

[BUGFIX release] fix router test regression in urlFor and recognize #19733

Merged
merged 1 commit into from
Aug 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/@ember/-internals/routing/lib/services/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ export default class RouterService extends Service {
@public
*/
urlFor(routeName: string, ...args: any[]) {
this._router.setupRouter();
return this._router.generate(routeName, ...args);
}

Expand Down Expand Up @@ -376,6 +377,7 @@ export default class RouterService extends Service {
`You must pass a url that begins with the application's rootURL "${this.rootURL}"`,
url.indexOf(this.rootURL) === 0
);
this._router.setupRouter();
let internalURL = cleanURL(url, this.rootURL);
return this._router._routerMicrolib.recognize(internalURL);
}
Expand All @@ -396,6 +398,7 @@ export default class RouterService extends Service {
`You must pass a url that begins with the application's rootURL "${this.rootURL}"`,
url.indexOf(this.rootURL) === 0
);
this._router.setupRouter();
let internalURL = cleanURL(url, this.rootURL);
return this._router._routerMicrolib.recognizeAndLoad(internalURL);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@ moduleFor(
}

['@test RouterService#urlFor returns url'](assert) {
let router = this.owner.lookup('router:main');
router.setupRouter();
assert.equal(this.routerService.urlFor('parent.child'), '/child');
}

['@test RouterService#transitionTo with basic route'](assert) {
assert.expect(2);

// Callers who want to actually execute a transition in a non-application
// test are doing something weird and therefore should do
// `owner.setupRouter()` explicitly in their tests.
let componentInstance;
let router = this.owner.lookup('router:main');
router.setupRouter();
Expand Down Expand Up @@ -107,8 +108,6 @@ moduleFor(
}

['@test RouterService#recognize recognize returns routeInfo'](assert) {
let router = this.owner.lookup('router:main');
router.setupRouter();
let routeInfo = this.routerService.recognize('/dynamic-with-child/123/1?a=b');
assert.ok(routeInfo);
let { name, localName, parent, child, params, queryParams, paramNames } = routeInfo;
Expand Down