From e2c8e5c22dfb615dd7e90edea7b805a837f1c10f Mon Sep 17 00:00:00 2001 From: Michael Dupuis Jr Date: Wed, 27 May 2015 15:39:11 -0400 Subject: [PATCH 1/2] Updates `assertValueNotEqual` to use label rather than selector. --- test-support/helpers/assertions.js | 13 +++++++------ tests/acceptance/actions-test.js | 7 +++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test-support/helpers/assertions.js b/test-support/helpers/assertions.js index 289a3f4..56f69aa 100644 --- a/test-support/helpers/assertions.js +++ b/test-support/helpers/assertions.js @@ -22,19 +22,20 @@ export function assertInputHasClass(assert, label, klass) { }; } -export function assertValueEquals(assert, label, expectedValue) { +export function assertValueEqual(assert, label, value) { return function() { const labelForInput = findLabelByText(label); - const value = findInputByLabel(labelForInput).val(); + const actualValue = findInputByLabel(labelForInput).val(); - assert.equal(value, expectedValue); + assert.equal(actualValue, value); } } -export function assertValueNotEqual(assert, selector, expectedValue, context = null) { +export function assertValueNotEqual(assert, label, value) { return function() { - const value = find(selector, context).val(); + const labelForInput = findLabelByText(label); + const actualValue = findInputByLabel(labelForInput).val(); - assert.notEqual(value, expectedValue); + assert.notEqual(actualValue, value); } } diff --git a/tests/acceptance/actions-test.js b/tests/acceptance/actions-test.js index a1335ef..ecb41c2 100644 --- a/tests/acceptance/actions-test.js +++ b/tests/acceptance/actions-test.js @@ -17,7 +17,7 @@ import { import { assertCurrentUrl, - assertValueEquals, + assertValueEqual, assertValueNotEqual } from '../helpers/assertions'; @@ -53,13 +53,12 @@ test('clickLink finds a link by its text and clicks it', function(assert) { }); test('fillInByLabel enters text into an input corresponding to a label', function(assert) { - const targetInput = 'form input.node-2'; const targetValue = 'Jane Doe'; assert.expect(2); visit('/'); - andThen(assertValueNotEqual(assert, targetInput, targetValue)); // sanity check + andThen(assertValueNotEqual(assert, 'Name', targetValue)); // sanity check andThen(fillInByLabel('Name', targetValue)); - andThen(assertValueEquals(assert, 'Name', targetValue)); + andThen(assertValueEqual(assert, 'Name', targetValue)); }); From 61e0e8a93d13b2fd95f85fdd08d616db6a40e0e0 Mon Sep 17 00:00:00 2001 From: Michael Dupuis Jr Date: Wed, 27 May 2015 15:39:41 -0400 Subject: [PATCH 2/2] Updates README with initials helpers. --- README.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3ba94b3..04104e4 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,24 @@ Status](https://travis-ci.org/dockyard/ember-cli-acceptance-test-helpers.svg?branch=master)](https://travis-ci.org/dockyard/ember-cli-acceptance-test-helpers) # ember-cli-acceptance-test-helpers -A set of declarative test helpers for acceptance testing. +This Ember addon includes a set of declarative test helpers for acceptance testing. + +## Installation +Install for [ember-cli](https://github.com/ember-cli/ember-cli): +`ember install ember-cli-acceptance-test-helpers` + +## Helpers +### Actions +* `clickButton(buttonText)` +* `clickLink(linkText)` +* `fillInByLabel(label, value)` + +### Assertions +* `assertCurrentUrl(assert, expectedUrl)` +* `assertInputHasClass(assert, label, klass)` +* `assertValueEqual(assert, label, value)` +* `assertValueNotEqual(assert, label, value)` + +### Finders +* `findInputByLabel(label)` +* `findLabelByText(text)`