小编Tyl*_*cks的帖子

如何在 Ember 中的组件上测试计算属性?

我有一个组件,foo-table我正在传递一个名为myList. 我正在对列表进行排序的组件上设置计算属性。见下文:

// app/components/foo-table.js
export default Component.extend({
  sortedList: computed('myList', function foo() {
    const myList = this.getWithDefault('myList', []);
    return myList.sortBy('bar');
  }),
});
Run Code Online (Sandbox Code Playgroud)

如何编写测试以确保计算属性已排序?这是我到目前为止:

// tests/integration/foo-table-test.js
const MY_LIST = ['foo', 'bar', 'baz']

test('it renders company industry component', function (assert) {
  this.set('myList', MY_LIST);

  this.render(hbs`
    {{foo-table myList=myList}}
  `);

  // TODO
  assert.equal(true, false);
});
Run Code Online (Sandbox Code Playgroud)

integration-testing ember.js

1
推荐指数
1
解决办法
1118
查看次数

标签 统计

ember.js ×1

integration-testing ×1