【发布时间】:2018-02-13 19:24:57
【问题描述】:
我试图在渲染组件之前简单地模拟计算的属性返回值。尝试this.set('isHome', true) 不起作用,因为我无法将它传递给组件。
组件[逻辑]:
isHome: false
组件[模板]:
{{#if isInbox}}
<p id="maintext">Text</p>
{{/if}}
测试:
test('Block is visible on the homepage', function(assert) {
assert.expect(1);
this.set('isHome', true); // Does nothing
this.render(template);
let maintext = this.$("#maintext")
this.asyncWait(assert, () => {
assert.ok(maintext);
});
});
这是一个非常粗略的布局轮廓,带有一个计算属性,然后用于在页面上显示或不显示块。如何将该计算属性覆盖为 true 以强制显示该块?
【问题讨论】:
标签: javascript unit-testing ember.js