The ArrayAssert object provides functions to test JavaScript array objects for a variety of cases.
_indexOfhaystack
needle
Simple indexOf() implementation for an array. Defers to native if available.
haystack
Array
The array to search.
needle
Any
The value to locate.
The index of the needle if found or -1 if not.
_somehaystack
matcher
Simple some() implementation for an array. Defers to native if available.
True if any value, when run through the matcher, returns true.
containsneedle
haystack
message
Asserts that a value is present in an array. This uses the triple equals sign so no type coercion may occur.
containsItemsneedles
haystack
message
Asserts that a set of values are present in an array. This uses the triple equals sign so no type coercion may occur. For this assertion to pass, all values must be found.
containsMatchmatcher
haystack
message
Asserts that a value matching some condition is present in an array. This uses a function to determine a match.
doesNotContainneedle
haystack
message
Asserts that a value is not present in an array. This uses the triple equals Asserts that a value is not present in an array. This uses the triple equals sign so no type coercion may occur.
doesNotContainItemsneedles
haystack
message
Asserts that a set of values are not present in an array. This uses the triple equals sign so no type coercion may occur. For this assertion to pass, all values must not be found.
doesNotContainMatchmatcher
haystack
message
Asserts that no values matching a condition are present in an array. This uses a function to determine a match.
indexOfneedle
haystack
index
message
Asserts that the given value is contained in an array at the specified index. This uses the triple equals sign so no type coercion will occur.
isEmptyactual
message
Asserts that an array is empty.
isNotEmptyactual
message
Asserts that an array is not empty.
isUniquearray
[comparator=null]
[message]
Asserts that given array doesn't contain duplicate items.
array
Array
The array to check.
[comparator=null]
Function
optional
A custom function to use to test the equality of two values. This function is similar to the one given to Y.Array.unique.
[message]
String
optional
The message to display if the assertion fails.
itemsAreEqualexpected
actual
message
Asserts that the values in an array are equal, and in the same position, as values in another array. This uses the double equals sign so type coercion may occur. Note that the array objects themselves need not be the same for this test to pass.
itemsAreEquivalentexpected
actual
comparator
message
Asserts that the values in an array are equivalent, and in the same position, as values in another array. This uses a function to determine if the values are equivalent. Note that the array objects themselves need not be the same for this test to pass.
itemsAreSameexpected
actual
message
Asserts that the values in an array are the same, and in the same position, as values in another array. This uses the triple equals sign so no type coercion will occur. Note that the array objects themselves need not be the same for this test to pass.
lastIndexOfneedle
haystack
index
message
Asserts that the given value is contained in an array at the specified index, starting from the back of the array. This uses the triple equals sign so no type coercion will occur.