Skip to content

Commit

Permalink
Specify the component should call the save action
Browse files Browse the repository at this point in the history
We reproduce the acceptance test error at the component level:

Inner Red: Expected submit handler to be called

Our code doesn't refer to this submitHandler attribute yet, so it's never called.
  • Loading branch information
Josh Justice authored and CodingItWrong committed Jan 12, 2019
1 parent adc2863 commit d788159
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tests/integration/components/post-form-test.js
@@ -1,6 +1,6 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { render, click } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

module('Integration | Component | post-form', function(hooks) {
Expand All @@ -12,4 +12,18 @@ module('Integration | Component | post-form', function(hooks) {
assert.dom('.js-post-form-title').exists();
assert.dom('.js-post-form-body').exists();
});

test('it calls the submit handler', async function(assert) {
let submitHandlerCalled = false;
this.set('testSubmitHandler', () => {
submitHandlerCalled = true;
});

await render(hbs`{{post-form submitHandler=(action testSubmitHandler)}}`);

await click('.js-post-form-save');

assert.ok(submitHandlerCalled,
"Expected submit handler to be called");
});
});

0 comments on commit d788159

Please sign in to comment.