Provides the main namespace, along with core abstractions.
Returns whether the arrays array and anotherArray are equivalent.
| Parameters: |
|
|---|---|
| Returns: | True if both arrays are equivalent; false otherwise. |
Returns whether obj is a matcher.
| Parameters: | obj – Object. |
|---|---|
| Returns: | True if the given object is a matcher; false otherwise. |
Library version.
Extends JsHamcrest.SimpleMatcher. Defines a composite matcher, that is, a matcher that wraps several matchers into one.
| Parameters: |
|
|---|
Wraps this matcher and the given matcher using JsHamcrest.Matchers.allOf().
| Parameters: | matcherOrValue – Instance of JsHamcrest.SimpleMatcher or a value. |
|---|---|
| Returns: | Instance of JsHamcrest.CombinableMatcher. |
Wraps this matcher and the given matcher using JsHamcrest.Matchers.anyOf().
| Parameters: | matcherOrValue – Instance of JsHamcrest.SimpleMatcher or a value. |
|---|---|
| Returns: | Instance of JsHamcrest.CombinableMatcher. |
Extends Object. Defines a textual description builder.
Appends text to this description.
| Parameters: | text – Text to append to this description. |
|---|---|
| Returns: | this. |
Appends the description of a self describing object to this description.
| Parameters: | selfDescribingObject – Any object that have a describeTo() function that accepts a JsHamcrest.Description object as argument. |
|---|---|
| Returns: | this. |
Appends the description of several self describing objects to this description.
| Parameters: |
|
|---|---|
| Returns: | this. |
Appends a JavaScript language’s literal to this description.
| Parameters: | literal – Literal to append to this description. |
|---|---|
| Returns: | this. |
Appends an array of values to this description.
| Parameters: |
|
|---|---|
| Returns: | this. |
Gets the current content of this description.
| Returns: | Current content of this description. |
|---|
Extends Object. Defines a matcher that relies on the external functions provided by the caller in order to shape the current matching logic.
Below, an example of matcher that matches middle-aged people:
var middleAged = new JsHamcrest.SimpleMatcher({
matches: function(person) {
return person.age >= 40 && person.age <= 60;
},
describeTo: function(description) {
description.append('middle-aged');
}
});
// Matcher usage
middleAged.matches({name:'Gregory', age:50}); // Expected: true
middleAged.matches({name:'Jeniffer', age:27}); // Expected: false
| Parameters: |
|
|---|
Describes this matcher’s tasks to description.
| Parameters: | description – Instance of JsHamcrest.Description. |
|---|---|
| Returns: | Nothing. |
Describes actual to description.
| Parameters: |
|
|---|---|
| Returns: | Nothing. |
Checks if this matcher matches actual.
| Parameters: | actual – Actual value. |
|---|---|
| Returns: | True if the matcher matches the actual value; false otherwise. |
See also