Skip to content
This repository was archived by the owner on Jul 26, 2023. It is now read-only.

added toBeDOMNodeOfType method #252

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ jasmine-jquery provides the following custom matchers (in alphabetical order):
- `toHaveValue(value)`
- only for elements on which `val` can be called (`input`, `textarea`, etc)
- e.g. `expect($('<input type="text" value="some text"/>')).toHaveValue('some text')`
- `toBeDOMNodeOfType(string)`
- Checks to see if a DOM element is of a certain type
- e.g. `expect($('<input type="text" />]').toBeDOMNodeOfType('text')`

The same as with standard Jasmine matchers, all of the above custom matchers may be inverted by using `.not` prefix, e.g.:

Expand Down
8 changes: 8 additions & 0 deletions lib/jasmine-jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,14 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
}
},

toBeDOMNodeOfType: function() {
return {
compare: function(actual, type) {
return { pass: $(actual).attr('type') === type }
}
}
},

toBeFocused: function (selector) {
return {
compare: function (actual, selector) {
Expand Down