Skip to content

Commit

Permalink
Repro for #19867
Browse files Browse the repository at this point in the history
  • Loading branch information
mixonic committed Dec 1, 2021
1 parent 147063f commit e88a74b
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion packages/@ember/-internals/routing/tests/system/route_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ moduleFor(

["@test 'store' can be injected by data persistence frameworks [DEPRECATED]"](assert) {
assert.expect(9);
expectDeprecation();
runDestroy(route);

let owner = buildOwner();
Expand All @@ -93,6 +92,51 @@ moduleFor(

route = owner.lookup('route:index');

expectDeprecation(
`A value for the \`store\` property was injected onto a route via the owner API. Implicit injection via the owner API is now deprecated, please add an explicit injection for this value. If the injected value is a service, consider using the @service decorator.`
);
assert.equal(route.model({ post_id: 1 }), post, '#model returns the correct post');
assert.equal(route.findModel('post', 1), post, '#findModel returns the correct post');

runDestroy(owner);
}

["@test 'store' can be injected by data persistence frameworks but explicitly injected"](
assert
) {
assert.expect(9);
runDestroy(route);

let owner = buildOwner();

let post = {
id: 1,
};

let Store = EmberObject.extend({
find(type, value) {
assert.ok(true, 'injected model was called');
assert.equal(type, 'post', 'correct type was called');
assert.equal(value, 1, 'correct value was called');
return post;
},
});

owner.register(
'route:index',
EmberRoute.extend({
store: injectService(),
})
);
owner.register('store:main', Store);
owner.register('service:store', Store);

owner.inject('route', 'store', 'store:main');

route = owner.lookup('route:index');

expectNoDeprecation();

assert.equal(route.model({ post_id: 1 }), post, '#model returns the correct post');
assert.equal(route.findModel('post', 1), post, '#findModel returns the correct post');

Expand Down

0 comments on commit e88a74b

Please sign in to comment.