dimanche 19 mars 2017

Ember - Get dynamic input value of element in component in test

So I have a simple component which looks like this:

<div class="my-div"></div>
<input class="my-input" type="text" value="" />

And I have two tests like this:

test('get text from div', function(assert) {

  this.set('value', 'my test value');
  this.render(hbs``);

  assert.equal(this.$('.my-div').text(), 'my test value');

});

test('get value from input', function(assert) {

  this.set('value', 'my test value');
  this.render(hbs``);

  assert.equal(this.$('.my-input').attr('value'), 'my test value');

});

The first test passes, but the second one fails. this.$('.my-input').attr('value') appears to be undefined. Why? How can I make this test pass?




Aucun commentaire:

Enregistrer un commentaire