Transform `this.on` usage.
rwjblue opened this issue · 2 comments
rwjblue commented
Given:
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
moduleForComponent('invokeAction', { integration: true });
test('it invokes a sendAction action', function(assert) {
assert.expect(1);
this.on('test', () => assert.ok(true));
this.render(hbs`{{test-component test="test"}}`);
});
We should output:
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
module('invokeAction', function(hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function() {
this.actions = {};
this.send = (actionName, ...args) => this.actions[actionName].apply(this, args));
});
test('it invokes a sendAction action', function(assert) {
assert.expect(1);
this.actions.test = () => assert.ok(true;
this.render(hbs`{{test-component test="test"}}`);
});
});
scottkidder commented
I had a rather difficult time finding this. Should we maybe add this to the examples here: https://github.com/emberjs/rfcs/blob/master/text/0232-simplify-qunit-testing-api.md#component--helper-integration-test or is there a more appropriate place for it?
rwjblue commented
Ya, we can add it there but I think we should start creating an “upgrading” section to ember-qunit’s README (that’s where we can track “current” state a but better)...