を使用して ember-cli qunit テストを使用してmoduleForComponent
います。作成した ember コンポーネント内に次の select 要素があります。
{{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
デバッガーでゲッターを使用してテストしたところ、すべてが期待どおりに機能しています。when
のいくつかのプロパティに別の条件が必要だと思いますがsiteMock
、何がわかりません。これを機能させるためのアドバイスを誰かに教えてもらえますか?