lundi 8 octobre 2018

How do I test a computed property on a component in Ember?

I have a component, foo-table that I am passing a list of objects, called myList. I'm setting a computed property on the component that sorts the list. See below:

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

How can I write a test to ensure the computed property is sorted? This is what I have so far:

// 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`
    
  `);

  // TODO
  assert.equal(true, false);
});




Aucun commentaire:

Enregistrer un commentaire