Permalink
Browse files

Add post-form component scaffold

`ember g component post-form`

Rather than just getting the test to pass by putting a form input on the route's template, we "write the code we wish we had." In this case, we wish we had a `post-form` component to use that would provide the form inputs for us. We generate it and go ahead and render it in our route template.
  • Loading branch information...
CodingItWrong committed Jan 10, 2018
1 parent 7a30c21 commit 393177c1feb554532d569e04db32686194f361f9
@@ -0,0 +1,4 @@
import Component from '@ember/component';
export default Component.extend({
});
@@ -0,0 +1 @@
{{yield}}
@@ -1 +1,3 @@
{{outlet}}
<h1>New Post</h1>
<PostForm />
@@ -0,0 +1,26 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
module('Integration | Component | post-form', function(hooks) {
setupRenderingTest(hooks);
test('it renders', async function(assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.set('myAction', function(val) { ... });
await render(hbs`{{post-form}}`);
assert.equal(this.element.textContent.trim(), '');
// Template block usage:
await render(hbs`
{{#post-form}}
template block text
{{/post-form}}
`);
assert.equal(this.element.textContent.trim(), 'template block text');
});
});

0 comments on commit 393177c

Please sign in to comment.