Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Specify the feature for creating a blog post
We set up the entire acceptance test at once. This test will guide us through the rest of the unit testing and implementation of the feature. Red: UnrecognizedURLError: /posts/new
- Loading branch information
1 parent
85c7956
commit 1c39e97
Showing
1 changed file
with
12 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,13 +1,21 @@ | |||
import { module, test } from 'qunit'; | import { module, test } from 'qunit'; | ||
import { visit, currentURL } from '@ember/test-helpers'; | import { visit, fillIn, click, currentRouteName } from '@ember/test-helpers'; | ||
import { setupApplicationTest } from 'ember-qunit'; | import { setupApplicationTest } from 'ember-qunit'; | ||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; | |||
|
|
||
module('Acceptance | creating a blog post', function(hooks) { | module('Acceptance | creating a blog post', function(hooks) { | ||
setupApplicationTest(hooks); | setupApplicationTest(hooks); | ||
setupMirage(hooks); | |||
|
|
||
test('visiting /creating-a-blog-post', async function(assert) { | test('creating a blog post', async function(assert) { | ||
await visit('/creating-a-blog-post'); | await visit('/posts/new'); | ||
|
|
||
assert.equal(currentURL(), '/creating-a-blog-post'); | await fillIn('.js-post-form-title', 'Test Post'); | ||
await fillIn('.js-post-form-body', 'This post is a test!'); | |||
await click('.js-post-form-save'); | |||
|
|||
assert.equal(currentRouteName(), 'posts.show'); | |||
assert.dom('.js-post-detail-title').hasText('Test Post'); | |||
assert.dom('.js-post-detail-body').hasText('This post is a test!'); | |||
}); | }); | ||
}); | }); |