|
| 1 | +import { module, test } from 'qunit'; |
| 2 | +import { setupApplicationTest } from 'ember-qunit'; |
| 3 | +import { click, fillIn, visit } from '@ember/test-helpers'; |
| 4 | + |
| 5 | +module('Acceptance | new person', function(hooks) { |
| 6 | + setupApplicationTest(hooks); |
| 7 | + |
| 8 | + test('it can create a person via mutation and handles an array response', async function(assert) { |
| 9 | + let newFirstName = 'Dave'; |
| 10 | + let newLastName = 'Jones'; |
| 11 | + let newAge = 44; |
| 12 | + |
| 13 | + assert.ok(this.server.db.people.length === 0) |
| 14 | + |
| 15 | + await visit(`/person-new`); |
| 16 | + |
| 17 | + |
| 18 | + let firstNameInput = this.element.querySelector('#person-first-name'); |
| 19 | + let lastNameInput = this.element.querySelector('#person-last-name'); |
| 20 | + let ageInput = this.element.querySelector('#person-age'); |
| 21 | + |
| 22 | + await fillIn(firstNameInput, newFirstName); |
| 23 | + await fillIn(lastNameInput, newLastName); |
| 24 | + await fillIn(ageInput, newAge); |
| 25 | + await click('.person-save'); |
| 26 | + |
| 27 | + let lastName = this.element.querySelector('.person-last-name'); |
| 28 | + |
| 29 | + assert.equal(lastName.textContent, newLastName, 'a person with with the correct last name was created'); |
| 30 | + assert.ok(this.server.db.people.length === 1, 'a new person was persisted to the DB') |
| 31 | + }); |
| 32 | +}) |
0 commit comments