javascript - Ember.js:测试时未重置组件属性

标签 javascript ember.js acceptance-testing ember-testing

我目前正在尝试对嵌套路由进行验收测试,它两次使用相同的组件,但参数不同。当我正常运行它时它工作正常,但是当我运行验收测试时,我注意到组件的参数没有更新,这导致我的测试失败。这是一些示例代码:

index.hbs 我有:

{{index-view model=model type='location'}}

我的 index-view 组件如下所示:

<h1>{{title}} List</h1>

{{listing-table model=model type=type}}

通过单击 listing-table 中的一个元素,然后转到 locations.show 路由,其中​​包含一个 link-to locations.show.devices 路线。 locations.show.devices 路由包含:

{{listing-table model=model.devices type='device' exclude='locationName'}}

但是,在我的验收测试中,我可以看到(通过在组件的 javascript 中回显这些属性)当 modeltype 正在更新时, exclude 始终设置为最初调用组件时设置的值。

现在,我已经检查(通过 console.log())组件是否被重用,我可以看到 init ()didDestroyElement () 被调用了两次,这意味着组件经历了整个生命周期两次。但是,我真的不明白为什么我的 exclude 参数根本没有更新,为什么这只在验收测试时发生?

This is a stripped down version of what I'm doing (当然它适用于 Twiddle,但不适用于现实生活!)。

最佳答案

{{listing-table model=model.devices type='device' exclude='locationName'}}

您传递的特定值 "locationName"(字符串)未链接到组件的属性 .locationName。 (我是关于 locationName 的引号)

你知道吗?

关于javascript - Ember.js:测试时未重置组件属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45682185/

相关文章:

JavaScript 的类 : toString() method

javascript - 如何使用 Moment.js 排除两个日期之间的周末

javascript - 正则表达式中 (?=foo) 的意义是什么 if (? :foo) already exists?

javascript - 如何随机化(洗牌)Javascript Set

ember.js - 使用 DS.FixtureAdapter 时无法查询 Emberjs 模型

json - 无法使用 Ember-Model 显示 JSON 数据

java - 瓦提更换

javascript - 如何编写 systemmd 脚本来运行 ember 服务器?

php - PHPUnit和 header 被发送

ruby-on-rails - Capybara-webkit 引发 Capybara::Driver::Webkit::WebkitInvalidResponseError