mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Add unit tests for jQuery.grep. Close gh-1345.
This commit is contained in:
parent
e7bdccacab
commit
b61a64224b
@ -967,6 +967,26 @@ test("jQuery.merge()", function() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("jQuery.grep()", function() {
|
||||||
|
expect(8);
|
||||||
|
|
||||||
|
var searchCriterion = function( value ) {
|
||||||
|
return value % 2 === 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
deepEqual( jQuery.grep( [], searchCriterion ), [], "Empty array" );
|
||||||
|
deepEqual( jQuery.grep( new Array(4), searchCriterion ), [], "Sparse array" );
|
||||||
|
|
||||||
|
deepEqual( jQuery.grep( [ 1, 2, 3, 4, 5, 6 ], searchCriterion ), [ 2, 4, 6 ], "Satisfying elements present" );
|
||||||
|
deepEqual( jQuery.grep( [ 1, 3, 5, 7], searchCriterion ), [], "Satisfying elements absent" );
|
||||||
|
|
||||||
|
deepEqual( jQuery.grep( [ 1, 2, 3, 4, 5, 6 ], searchCriterion, true ), [ 1, 3, 5 ], "Satisfying elements present and grep inverted" );
|
||||||
|
deepEqual( jQuery.grep( [ 1, 3, 5, 7], searchCriterion, true ), [1, 3, 5, 7], "Satisfying elements absent and grep inverted" );
|
||||||
|
|
||||||
|
deepEqual( jQuery.grep( [ 1, 2, 3, 4, 5, 6 ], searchCriterion, false ), [ 2, 4, 6 ], "Satisfying elements present but grep explicitly uninverted" );
|
||||||
|
deepEqual( jQuery.grep( [ 1, 3, 5, 7 ], searchCriterion, false ), [], "Satisfying elements absent and grep explicitly uninverted" );
|
||||||
|
});
|
||||||
|
|
||||||
test("jQuery.extend(Object, Object)", function() {
|
test("jQuery.extend(Object, Object)", function() {
|
||||||
expect(28);
|
expect(28);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user