ixSci
ixSci

Reputation: 13698

Check if the component action gets called in an integration test

I have the following simple component:

export default Ember.Component.extend({
  actions:{
    someAction(){
      //...
    }
  }
});

What should I do(in an integration test) if I want to check if this action gets called in the corresponding hbs file?

Upvotes: 0

Views: 372

Answers (1)

Marek Grác
Marek Grác

Reputation: 773

I'm using following code for integration tests of component

assert.expect(numberOfAssertionsInYourTest)

this.set('onClick', () => {
  assert.ok(true, 'Closure action after click on item was executed');
});

this.render(hbs`{{menu-item title='Hello' onClickAction=(action onClick)}}`);

this.$('.menu-item').click()

The second option is to test results of your actions. I use this option mostly for actions that are implemented in components (e.g. collapse/expand)

Upvotes: 1

Related Questions