我正在使用 ember-cli qunit 测试moduleForComponent
。我在创建的 ember 组件中有以下选择元素。
{{input site as="select"
collection="sites"
selection="site"
optionLabelPath="content.siteLabel"
optionValuePath="content.id"
prompt="Please Select"
label=" "
}}
使用. sites
_store
sites : function() {
return this.get('store').find('site');
}.property()
我正在使用jsMockito来模拟store
.
var siteMock = mock(DS.Model);
when(siteMock).get('id').thenReturn(1);
when(siteMock).get('siteLabel').thenReturn('Qunit');
var storeMock = mock(DS.Store);
when(storeMock).find('site').thenReturn([siteMock]);
我将它作为测试中的参数传递给组件。
var component = this.subject({
store : storeMock
});
生成的 html 看起来像这样,似乎 siteMock 已呈现,但即使我在模拟上添加了适当的期望 optionLabelPath
,也无法正常工作。optionValuPath
<select id="ember473" class="ember-view ember-select">
<option value="">Please Select</option>
<option id="ember491" class="ember-view" value=""></option>
</select>
我已经siteMock
在调试器中使用 getter 进行了测试,一切都按预期工作。我想我需要when
对某些属性的另一个条件,siteMock
但我不确定是什么。任何人都可以给我一些关于让这个工作的建议吗?