Permalink
Browse files

Specify detail component should display model fields

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...
CodingItWrong committed Jan 11, 2018
1 parent 1b635b9 commit 6d35eee930a58f847fb97c3dd09a873fec57dee2
Showing with 8 additions and 14 deletions.
  1. +8 −14 tests/integration/components/post-detail-test.js
@@ -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 6d35eee

Please sign in to comment.