-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from Turbo87/disabled
Merge `isDisabled` and `isNotDisabled` helpers
- Loading branch information
Showing
4 changed files
with
133 additions
and
76 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,34 @@ | ||
export default function isDisabled(message, options = {}) { | ||
let { inverted } = options; | ||
|
||
let element = this.findTargetElement(); | ||
if (!element) return; | ||
|
||
if (!( | ||
element instanceof HTMLInputElement || | ||
element instanceof HTMLTextAreaElement || | ||
element instanceof HTMLSelectElement || | ||
element instanceof HTMLButtonElement || | ||
element instanceof HTMLOptGroupElement || | ||
element instanceof HTMLOptionElement || | ||
element instanceof HTMLFieldSetElement | ||
)) { | ||
throw new TypeError(`Unexpected Element Type: ${element.toString()}`); | ||
} | ||
|
||
let result = element.disabled === !inverted; | ||
|
||
let actual = element.disabled === false | ||
? `Element ${this.targetDescription} is not disabled` | ||
: `Element ${this.targetDescription} is disabled`; | ||
|
||
let expected = inverted | ||
? `Element ${this.targetDescription} is not disabled` | ||
: `Element ${this.targetDescription} is disabled`; | ||
|
||
if (!message) { | ||
message = expected; | ||
} | ||
|
||
this.pushResult({ result, actual, expected, message }); | ||
} |
This file was deleted.
Oops, something went wrong.