Permalink
Browse files

Specify show page should display model from the database

Outer red:
✘ Element .js-post-detail-title has text "Test Post"
✘ Element .js-post-detail-body has text "This post is a test!"

We create a new acceptance test for viewing a page. We use Mirage's `server.create()` method to create a test post directly in our fake backend. We specify
that, when the post view page is shown, the post's title and body are visible.

The test fails because no title is being outputted on the page. This is the problem that happens when we don't define attributes on our model.
  • Loading branch information...
CodingItWrong committed Jan 11, 2018
1 parent 8f2020c commit 87c29f27dcfdf6e241361031cf1b6bae6155c936
Showing with 20 additions and 0 deletions.
  1. +20 −0 tests/acceptance/viewing-a-blog-post-test.js
@@ -0,0 +1,20 @@
import { module, test } from 'qunit';
import { visit } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
module('Acceptance | viewing a blog post', function(hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
test('viewing a blog post', async function(assert) {
let post = server.create('post', {
title: 'Test Post',
body: 'This post is a test!'
});
await visit(`/posts/${post.id}`);
assert.dom('.js-post-detail-title').hasText('Test Post');
assert.dom('.js-post-detail-body').hasText('This post is a test!');
});
});

0 comments on commit 87c29f2

Please sign in to comment.