我有一个组件listing-table
这需要一些属性的,就像这样:Ember.js:消失的组件特性,同时执行验收测试
{{listing-table model=model.devices type='user' exclude='customerName'}}
这如预期运作,并集成测试也工作得很好。但是,我的验收测试失败,因为显然我的exclude
属性在运行验收测试时未被考虑到。
我已通过打印测试该组件的javascript文件中的值为this.get('exclude')
并获得undefined
。但是,例如打印this.get('type')
会产生预期结果。
我已经那么,出于测试目的,去除exclude
并用它取代type
的价值,即type='endpointName,typeName'
,但是,我会在控制台中,如以前的值user
。
这完全是令人费解的,我真的很想知道验收测试有什么问题。任何类型的提示都比欢迎,并感谢您的时间!
编辑:
我现在已经编辑我的验收测试,以排除点击通过各种元素去包含我listing-table
组件路线:
来源:
visit('/users/1')
click('a:contains("Devices")')
收件人:
visit('/users/1/devices')
并且测试通过。我仍然不明白为什么点击会使我的组件的属性消失,而直接访问页面可以很好地工作。
编辑2:
所以,这里是一些示例代码。这是我的测试样子:
test('/customers/1/devices should display 5 devices', function (assert) {
let type = server.create('endpoint-type')
let user = server.create('user')
let endpoint = server.create('endpoint', { type })
server.createList('device', 5, { user })
visit('/customers');
click('a:contains("Customer 0")')
click('a:contains("Devices")')
andThen(function() {
assert.equal(find('.device-listing').length, 5, 'should see 5 listings')
assert.equal(find('th').text().trim(), 'IDModelManufacturerMACExtensionLocation', 'should only contain ID, Model, Manufacturer, MAC, Extension, and Location columns')
})
现在,我的设备表应,在这种情况下,忽略“客户”列,但该列会出现在那里,即使我在devices.show.customers
组件已与调用:
{{listing-table model=model.devices type='user' exclude='customerName'}}
我listing-table.js
文件基本上都采用this.get('exclude')
的init()
函数内部处理排除,但正如我所说,如果我在文件中添加一个console.log(this.get('exclude')
,我得到undefined
。
编辑3:
更多的测试后,我已经取得了一些进展,并将得到的问题,需要有自己的网页,here。
感谢您的反馈! 1.是的,我正在使用'andThen()'; 2.即使模型钩子没有被触发,为什么在浏览器中运行同样的过程却在测试环境中运行时失败? 我会用一些代码更新我的原始问题。再次感谢。 – finferflu