Ember.js: Component attribute not reset while testing

纵饮孤独 提交于 2019-12-08 22:10:16

问题


I am currently attempting an acceptance test on a nested route, which makes use of the same component twice, but with different arguments. This works fine when I run it normally, however as I run the acceptance test, I notice that the component's arguments aren't being updated, which causes my test to fail. Here is some sample code:

In index.hbs I have:

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

My index-view component looks like this:

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

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

By clicking on an element in the listing-table, I then go to the locations.show route, which contains a link-to the locations.show.devices route. The locations.show.devices route contains:

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

However, in my acceptance tests, I can see (by echoing out these attributes in the component's javascript) that while model and type are being updated, exclude is always set to whatever was set when the component was initially called.

Now, I have checked (via console.log()) whether the component is being reused or not, and I could see that both init () and didDestroyElement () are called twice, which means that the component goes through an entire lifecycle twice. However, I can't really understand why my exclude argument is not being updated at all, and why does this only happen while acceptance testing?

This is a stripped down version of what I'm doing (of course it works on Twiddle, but not in real life!).


回答1:


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

you pass certain value "locationName" ( string ) not link to the property .locationName of component . ( I'm about quotes around locationName )

You know, yes?



来源:https://stackoverflow.com/questions/45682185/ember-js-component-attribute-not-reset-while-testing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!