Permalink
Browse files

Specify form should send the form data

We add a component test case specifying that the post form should send the data from the form fields into the submit handler.

Inner red: Cannot read property 'title' of undefined

This means that no postData object is being sent into the submit handler at all.
  • Loading branch information...
CodingItWrong committed Jan 11, 2018
1 parent 231c445 commit 12303cf303d482261d762e01d3959b4353a7f479
Showing with 7 additions and 3 deletions.
  1. +7 −3 tests/integration/components/post-form-test.js
@@ -1,6 +1,6 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, click } from '@ember/test-helpers';
import { render, fillIn, click } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

module('Integration | Component | post-form', function(hooks) {
@@ -13,14 +13,18 @@ module('Integration | Component | post-form', function(hooks) {
assert.dom('.js-post-form-body').exists();
});

test('it calls the submit handler', async function(assert) {
test('it calls the submit handler with the form data', async function(assert) {
let submitHandlerCalled = false;
this.set('testSubmitHandler', () => {
this.set('testSubmitHandler', postData => {
submitHandlerCalled = true;
assert.equal(postData.title, 'New Title');
assert.equal(postData.body, 'New Body');
});

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

await fillIn('.js-post-form-title', 'New Title');
await fillIn('.js-post-form-body', 'New Body');
await click('.js-post-form-save');

assert.ok(submitHandlerCalled,

0 comments on commit 12303cf

Please sign in to comment.