In my app I have this initializer which injects the store into all services:
export function initialize(container, application) {
application.inject('service', 'store', 'store:main');
}
export default {
name: 'inject-store-in-services',
initialize: initialize
};
My problem is that when I run unit tests, services don’t have the store
property. So my question: is there a way to achieve what my initializer does but inside a unit test context?
In my app I have this initializer which injects the store into all services:
export function initialize(container, application) {
application.inject('service', 'store', 'store:main');
}
export default {
name: 'inject-store-in-services',
initialize: initialize
};
My problem is that when I run unit tests, services don’t have the store
property. So my question: is there a way to achieve what my initializer does but inside a unit test context?
DS.Model
with the correct properties set. Mocking the store would just test my mocks so...
– charles_demers
Commented
Apr 3, 2015 at 14:24
In recent versions of Ember you can inject the store as a service, e.g:
Ember.Service.extend({
store: Ember.inject.service()
});
It gets the service name from the property name, so if you call it something else you need to specify 'store'.. e.g:
Ember.Service.extend({
banana: Ember.inject.service('store')
});