This repository has been archived by the owner on Jun 20, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce
check
and uncheck
async helpers
Promotes `check` and `uncheck` test helpers from [emberjs/ember.js] from behind the [ember-testing-checkbox-helpers] feature flag. Matches Capybara's [#check] and [#uncheck] helper methods. Additionally introduces `assert.checked` and `assert.unchecked` QUnit assertions. [ember-testing-checkbox-helpers]: https://github.com/emberjs/ember.js/blob/860bb4be498466ac4c914adb1f139e5cd2fbc123/FEATURES.md#feature-flags [emberjs/ember.js]: emberjs/ember.js#9798 [#check]: http://www.rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Actions#check-instance_method [#uncheck]: http://www.rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Actions#uncheck-instance_method
- Loading branch information
1 parent
883141c
commit 6797f79
Showing
9 changed files
with
104 additions
and
5 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
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
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import Ember from 'ember'; | ||
|
||
const { assert, run } = Ember; | ||
|
||
function ensureCheckState(isChecked, app, selector, context) { | ||
const { | ||
click, | ||
findWithAssert | ||
} = app.testHelpers; | ||
const word = isChecked ? 'check' : 'uncheck'; | ||
|
||
const $element = findWithAssert(selector, context); | ||
assert( | ||
`To ${word} '${selector}', the input must be a checkbox`, | ||
$element.prop('type') === 'checkbox' | ||
); | ||
|
||
run(() => { | ||
if ($element.is(':checked') !== isChecked) { | ||
click($element); | ||
} | ||
}); | ||
} | ||
|
||
Ember.Test.registerAsyncHelper('check', function() { | ||
ensureCheckState(true, ...arguments); | ||
}); | ||
|
||
Ember.Test.registerAsyncHelper('uncheck', function() { | ||
ensureCheckState(false, ...arguments); | ||
}); |
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
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
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 | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
import 'ralphs-little-helpers/checkbox-helpers'; | ||
import 'ralphs-little-helpers/within'; |
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 | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
{ | ||
"predef": [ | ||
"check", | ||
"uncheck", | ||
"within", | ||
"document", | ||
"window", | ||
|
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
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