Skip to content

Commit

Permalink
Add failing test for router service default QPs
Browse files Browse the repository at this point in the history
  • Loading branch information
wagenet committed Feb 14, 2022
1 parent 8455848 commit b9fa54d
Showing 1 changed file with 50 additions and 0 deletions.
Expand Up @@ -136,5 +136,55 @@ moduleFor(
assert.deepEqual(this.state, ['/', '/child?sort=ASC']);
});
}

['@test RouterService#replaceWith with basic query params does include unspecified defaults'](
assert
) {
assert.expect(3);

this.add(
'controller:parent.child',
Controller.extend({
queryParams: ['sort'],
sort: 'ASC',
})
);

return this.visit('/')
.then(() => {
return this.routerService.transitionTo('parent.brother');
})
.then(() => {
return this.routerService.replaceWith('parent.sister');
})
.then(() => {
let controller = this.applicationInstance.lookup('controller:parent.child');
expectDeprecation(
() => controller.replaceRoute('parent.child'),
'Calling replaceRoute on a controller is deprecated. Use the RouterService instead.'
);
})
.then(() => {
assert.deepEqual(
this.state,
['/', '/child'],
'no default params when loaded with Controller#replaceRoute'
);

// Leave the route...
return this.routerService.transitionTo('parent.brother');
})
.then(() => {
// ...and come back with the router service
return this.routerService.replaceWith('parent.child');
})
.then(() => {
assert.deepEqual(
this.state,
['/', '/child'],
'no default params when loaded with Router#replaceWith'
);
});
}
}
);

0 comments on commit b9fa54d

Please sign in to comment.