Я смотрю на руководства по тестированию Ember, и в них говорится, что нужно сделать следующее, когда вы хотите заглушить службу.
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
import Ember from 'ember';
//Stub location service
const locationStub = Ember.Service.extend({
city: 'New York',
country: 'USA',
currentLocation: {
x: 1234,
y: 5678
},
getCurrentCity() {
return this.get('city');
},
getCurrentCountry() {
return this.get('country');
}
});
moduleForComponent('location-indicator', 'Integration | Component | location indicator', {
integration: true,
beforeEach: function () {
this.register('service:location-service', locationStub);
this.inject.service('location-service', { as: 'location' });
}
});
Проблема в том, что я получаю Uncaught TypeError: this.register is not a function
, когда использую этот код. Итак, я предполагаю, что перед каждым this.register('service:location-service', locationStub);
возникает проблема.
Кто-нибудь знает, как я могу обойти это или какой более правильный способ отключить службу? Этот код в настоящее время находится в документации Ember.