Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this.on() no longer supported in rendering tests? #232

Closed
bendemboski opened this issue Nov 3, 2017 · 3 comments
Closed

this.on() no longer supported in rendering tests? #232

bendemboski opened this issue Nov 3, 2017 · 3 comments

Comments

@bendemboski
Copy link
Contributor

bendemboski commented Nov 3, 2017

Using 0.6.x I pretty commonly use this pattern in component integration tests:

let onClick = sinon.stub();
this.on('onClick', onClick);

this.render(hbs`{{app-toolbar/button src=src text=text onClick=(action 'onClick')}}`);
this.$('[data-test-app-toolbar-button]').click();

In 0.7.x it looks like this.on() no longer exists. Is this intentional? I suppose I can do

let onClick = sinon.stub();
this.set('onClick', onClick);

this.render(hbs`{{app-toolbar/button src=src text=text onClick=onClick}}`);
this.$('[data-test-app-toolbar-button]').click();

but I like the explicit-ness of using the action helper in the template to make it really clear that it's an action being passed in. I can certainly live without it, I'm just wondering if it was intentionally removed, or if it was an oversight.

@bendemboski
Copy link
Contributor Author

Actually, thinking for like 10 more seconds I guess I can do this:

let onClick = sinon.stub();
this.set('onClick', onClick);

this.render(hbs`{{app-toolbar/button src=src text=text onClick=(action onClick)}}`);
this.$('[data-test-app-toolbar-button]').click();

But I'm still curious to know if this was an intentional feature removal.

@rwjblue
Copy link
Member

rwjblue commented Nov 3, 2017

Yep, that’s exactly what you should do. The this.on API was only needed for supporting string based actions (which are slowly becoming much less common).

Also, FWIW, I just landed a PR in Ember-qunit-codemod to transform this.on to the new API. I think it may need more work because we should probably just rewrite to using this.set when closure actions are being used directly (instead of adding a custom this.send).

@rwjblue
Copy link
Member

rwjblue commented Nov 3, 2017

We also need to start fleshing out a better migration guide from ember-qunit@2 to Ember-qunit@3 showing the various permutations of things that folks should be doing...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants