I'm trying to unit test an EmberJS component. Specifically, I want to verify that the component loses focus when the tab key is pressed. When I run the test, there is a call to focus the component. Then a trigger event that sends the tab key is sent. At this point, I get an error that the element cannot be found. Any ideas. Here's the code:
it('should behave as expected', function() {
var component = this.subject();
this.render();
expect(component.get('id')).to.equal('textareaId');
$('#textareaId').focus();
expect($("#textareaId").is(":focus")).to.equal(true);
triggerEvent('#textareaId', 'keydown', { keyCode: 9, which: 9 });
andThen(function(){
expect($("#textareaId").is(":focus")).to.equal(false);
});
});
});
Aucun commentaire:
Enregistrer un commentaire