Skip to content

Commit 190136c

Browse files
committed
Unit test for this case
Codestyle fixes
1 parent 9c18eb2 commit 190136c

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/core.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,8 +678,7 @@ jQuery.extend({
678678
},
679679

680680
inArray: function( elem, array ) {
681-
if (!jQuery.isArray(array))
682-
{
681+
if ( !array ) {
683682
return -1;
684683
}
685684

test/unit/core.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,16 @@ test("jQuery.makeArray", function(){
916916
same( jQuery.makeArray({length: "5"}), [], "Make sure object is coerced properly.");
917917
});
918918

919+
test("jQuery.inArray", function(){
920+
expect(3);
921+
922+
equals( jQuery.inArray( 0, false ), -1 , "Search in 'false' as array returns -1 and doesn't throw exception" );
923+
924+
equals( jQuery.inArray( 0, null ), -1 , "Search in 'null' as array returns -1 and doesn't throw exception" );
925+
926+
equals( jQuery.inArray( 0, undefined ), -1 , "Search in 'undefined' as array returns -1 and doesn't throw exception" );
927+
});
928+
919929
test("jQuery.isEmptyObject", function(){
920930
expect(2);
921931

0 commit comments

Comments
 (0)