-
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.
Extract half-generated "API.md" from README and JSDoc
- Loading branch information
Showing
3 changed files
with
124 additions
and
51 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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
# API | ||
|
||
[htmlelement]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement | ||
|
||
[nodelist]: https://developer.mozilla.org/en-US/docs/Web/API/NodeList | ||
|
||
## assert.dom() | ||
|
||
Once installed the DOM element assertions are available at `assert.dom(...).*`: | ||
|
||
**Parameters** | ||
|
||
- `target` **([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [HTMLElement](https://developer.mozilla.org/en-US/docs/Web/HTML/Element))** A CSS selector that can be used to find elements using [`querySelector()`](https://developer.mozilla.org/de/docs/Web/API/Document/querySelector), or an [HTMLElement][] (Not all assertions support both target types.) | ||
- `rootElement` **[HTMLElement](https://developer.mozilla.org/en-US/docs/Web/HTML/Element)?** The root element of the DOM in which to search for the `target` (optional, default `document`) | ||
|
||
**Examples** | ||
|
||
```javascript | ||
test('the title exists', function(assert) { | ||
assert.dom('#title').exists(); | ||
}); | ||
``` | ||
|
||
## Assertions | ||
|
||
<!-- Generated by documentation.js. Update this documentation by updating the source code. --> | ||
|
||
### exists | ||
|
||
Assert an [HTMLElement][] (or multiple) matching the `selector` exists. | ||
|
||
**Parameters** | ||
|
||
- `options` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)?** | ||
- `message` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** | ||
|
||
**Examples** | ||
|
||
```javascript | ||
assert.dom('#title').exists(); | ||
assert.dom('.choice').exists({ count: 4 }); | ||
``` | ||
|
||
### missing | ||
|
||
Assert an [HTMLElement][] matching the `selector` does not exists. | ||
|
||
**Parameters** | ||
|
||
- `message` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** | ||
|
||
**Examples** | ||
|
||
```javascript | ||
assert.dom('.should-not-exist').missing(); | ||
``` | ||
|
||
### focused | ||
|
||
Assert that the [HTMLElement][] or an [HTMLElement][] matching the | ||
`selector` is currently focused. | ||
|
||
**Parameters** | ||
|
||
- `message` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** | ||
|
||
**Examples** | ||
|
||
```javascript | ||
assert.dom('input.email').focused(); | ||
``` | ||
|
||
### notFocused | ||
|
||
Assert that the [HTMLElement][] or an [HTMLElement][] matching the | ||
`selector` is not currently focused. | ||
|
||
**Parameters** | ||
|
||
- `message` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** | ||
|
||
**Examples** | ||
|
||
```javascript | ||
assert.dom('input[type="password"]').notFocused(); | ||
``` | ||
|
||
### textContains | ||
|
||
Assert that the text of the [HTMLElement][] or an [HTMLElement][] | ||
matching the `selector` contains the given `text`, using the | ||
[`textContent`](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent) | ||
attribute. | ||
|
||
**Parameters** | ||
|
||
- `text` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** | ||
- `message` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** | ||
|
||
**Examples** | ||
|
||
```javascript | ||
assert.dom('#title').textContains('Welcome'); | ||
``` | ||
|
||
### textMatches | ||
|
||
Assert that the text of the [HTMLElement][] or an [HTMLElement][] | ||
matching the `selector` matches the given regular expression, using the | ||
[`textContent`](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent) | ||
attribute. | ||
|
||
**Parameters** | ||
|
||
- `regex` **[RegExp](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp)** | ||
- `message` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** | ||
|
||
**Examples** | ||
|
||
```javascript | ||
assert.dom('.foo').textMatches(/[12]\d{3}/); | ||
``` |
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