Skip to content

Commit

Permalink
Specify detail component should display model fields
Browse files Browse the repository at this point in the history
We add a component test that reproduces the acceptance test error: we specify that the component displays the post's title. And we go ahead and specify that it displays the body, too, because that seems safe in this case.

Inner red:
✘ Element .js-post-detail-title exists
✘ Element .js-post-detail-body exists

This means that the title field was not found, to be able to retrieve the textContent from it.
  • Loading branch information
Josh Justice authored and CodingItWrong committed Jan 12, 2019
1 parent 8a76c25 commit 8da861b
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions tests/integration/components/post-detail-test.js
Expand Up @@ -6,21 +6,15 @@ import hbs from 'htmlbars-inline-precompile';
module('Integration | Component | post-detail', 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) { ... });
test('it displays details for the passed-in post', async function(assert) {
this.set('testModel', {
title: 'Test Title',
body: 'This is a test post!',
});

await render(hbs`{{post-detail}}`);
await render(hbs`{{post-detail post=testModel}}`);

assert.equal(this.element.textContent.trim(), '');

// Template block usage:
await render(hbs`
{{#post-detail}}
template block text
{{/post-detail}}
`);

assert.equal(this.element.textContent.trim(), 'template block text');
assert.dom('.js-post-detail-title').hasText('Test Title');
assert.dom('.js-post-detail-body').hasText('This is a test post!');
});
});

0 comments on commit 8da861b

Please sign in to comment.