Ensure _.has treats sparse arrays as dense.

This commit is contained in:
jdalton
2015-05-12 08:44:02 -07:00
parent c6ff845ecb
commit e3be2b4451
2 changed files with 22 additions and 7 deletions

View File

@@ -6248,6 +6248,8 @@
QUnit.module('lodash.has');
(function() {
var args = arguments;
test('should check for own properties', 2, function() {
var object = { 'a': 1 };
@@ -6311,6 +6313,14 @@
});
});
test('should treat sparse arrays as dense', 1, function() {
strictEqual(_.has(Array(1), 0), true);
});
test('should work with `arguments` objects', 1, function() {
strictEqual(_.has(args, 1), true);
});
test('should check for a key over a path', 2, function() {
var object = { 'a.b.c': 3, 'a': { 'b': { 'c': 4 } } };
@@ -6352,7 +6362,7 @@
strictEqual(_.has(object, path), false);
});
});
}());
}(1, 2, 3));
/*--------------------------------------------------------------------------*/