CodeJr
CodeJr

Reputation: 47

Ember tests: checkbox

I'm developing ember tests and I want to check if error messages are correctly displayed. For that I need to check a specific checkbox (or groups of checkboxes) from a list. Is there a way to specify which checkboxes we want? Maybe using some kind of parameter that we can pass to choose which we want to select? Thanks

Upvotes: 0

Views: 413

Answers (1)

CodeJr
CodeJr

Reputation: 47

I figure out how to solve it. I used a collection to identify the elements. Thanks all for your help!

//products.js

export default create({
  main: {
    scope: '#main',
    allProducts: collection({
      itemScope: '.products-list',
      item: {
        name: text('.card-h1'),
        click: clickable('.card-h1'),
        color: text('.product-color'),
        quantity: text('.product-quantity'),
      },
    }),
  }
});

// products-test.js

function getSingleProduct(name) {
  return products.main.allProducts()
    .filter(p => p.name.trim() === name).get(0);
}

assert.equal(product.color, 'red');
assert.equal(product.quantity, 10);

Upvotes: 0

Related Questions