lundi 1 août 2016

Ember component unit testing inject service defined in initalizer

I am writing a unit test case for my component.

Ember 0.12, Ember-qunit 0.3.13 Ember-i18n: "4.1.1",

I am initialising this i18n service in via Ember initaliazers, so that i can access i18n serivces as this.i18n.t('some key'). which i am using in my component

some: computed('', {
 get(){
   this.i18n.t('somekey') + "Test"
 }
})

My component unit test for this component fails, because i am not able to inject the i18n service. Please help me in solving it and i tried

needs: ['serivces:i18n'] it wont work because i have initialised via Intializers Issue injecting via initalizer

and the below code also wont work because i am using older version of ember-qunit (Please i don't wont to update to newest version because it affects all other test cases)

 this.register('service:user-session', userSession);
 this.inject.service('user-session', { as: 'userSession' });

Help me in solving in this issue , if there is a need for more clarity in the question , please do comment. Thanks

Aucun commentaire:

Enregistrer un commentaire