Skip to content

Commit

Permalink
Add submitForm action
Browse files Browse the repository at this point in the history
To get the submitHandler called, we add a submitForm action on the component, so that it will be called when the form is submitted. Then we retrieve the "submitHandler" property of the component, and call it as a function.

Inner green; outer red: TypeError: this.submitHandler is not a function

Now our component test is able to verify that the submit handler is called. Now the acceptance test errors out because submitting the form expects a submitHandler to be passed in, and there isn't one.
  • Loading branch information
Josh Justice authored and CodingItWrong committed Sep 6, 2018
1 parent d18f8a9 commit a4a10c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/components/post-form.js
@@ -1,4 +1,9 @@
import Component from '@ember/component';

export default Component.extend({
actions: {
submitForm() {
this.submitHandler();
}
}
});
2 changes: 1 addition & 1 deletion app/templates/components/post-form.hbs
Expand Up @@ -8,5 +8,5 @@
<textarea class="js-post-form-body" />
</div>

<button type="button" class="js-post-form-save">Save</button>
<button type="button" class="js-post-form-save" onclick={{action "submitForm"}}>Save</button>
</form>

0 comments on commit a4a10c6

Please sign in to comment.