I injected mock service to test, but while I run this test, the service is undefined. But in console log I see it.
Component
didInsertElement: function () {
this._super(...arguments);
let self = this;
_moment = this.get('datetimeService').getMoment();
Test
const datetimeService = Ember.Service.extend({
getDateTime(){
return {rangeStart: 1478003235171, rangeEnd: 1478006835170};
},
getMoment(){
return window.moment;
}
});
moduleForComponent('date-time', 'Integration | Component | date time', {
integration: true,
beforeEach: function () {
this.register('service:datetime-service', datetimeService);
this.inject.service('datetime-service', { as: 'datetimeService' });
}
});
test('it renders', function(assert) {
assert.expect(1);
console.log('k moment:: ', this.get('datetimeService').getMoment());
this.render(hbs`
{{date-time}}
`);
assert.ok(this.$('#reportrange'));
});