我有一个使用this.get('model.property')
的组件,它可以按预期工作。Ember.js + Mirage:在集成测试中拉扯嘲弄的关系
对于我使用的是幻影,这已为我所有的其他测试工作(集成测试包括)我的集成测试,但是当我测试这个特定组件,我得到:
TypeError: Cannot read property 'then' of undefined
这是什么我的测试看起来像:
import { moduleForComponent, test } from 'ember-qunit'
import hbs from 'htmlbars-inline-precompile'
import { startMirage } from 'app/initializers/ember-cli-mirage'
import Ember from 'ember'
moduleForComponent('summary-card', 'Integration | Component | summary card', {
integration: true,
beforeEach() {
this.server = startMirage()
},
afterEach() {
this.server.shutdown()
}
})
test('it renders', function(assert) {
const customer = this.server.create('customer')
const location = this.server.create('location', { customer })
const manufacturer = this.server.create('manufacturer')
const model = this.server.create('device-model', { manufacturer })
this.server.createList('device', 5, { model, customer, location })
const loc = Ember.Object.create(location)
this.set('model', loc)
this.render(hbs`{{summary-card model=model model-name=model.name tag='location' belongs-to='customer' has-many='device'}}`);
assert.equal(this.$('h1').text().trim(), 'Location 0', 'should be titled Location 0')
});
,基本上,我summary-card.js
有这样的事情:
this.get('model.' + belongs).then(relationship => {...})
其中belongs
只是调用组件时设置的任何belongs-to
的值。
我有点困惑,因为它看起来像我传递给我的测试的模拟模型并不像真正代表模型一样运行ember s
(我使用Mirage进行开发以及)。有什么地方可以找到更多关于那里到底发生了什么的吗?
谢谢!
P.S.我也尝试使用尽可能由server.create()
提供location
对象,我得到一个稍微不同的错误:
TypeError: _this.get(...).then is not a function