Add test for _.at and non-index keys on array-like values.

This commit is contained in:
John-David Dalton
2014-11-06 20:45:18 -08:00
parent ad87df3168
commit 3ffa6cd1ac

View File

@@ -935,6 +935,20 @@
deepEqual(actual, ['c', undefined, 'a']);
});
test('should use `undefined` for non-index keys on array-like values', 1, function() {
var array = ['a', 'b', 'c'];
array['1.1'] = array['-1'] = 1;
var values = _.reject(empties, function(value) {
return value === 0 || _.isArray(value);
}).concat(-1, 1.1);
var expected = _.map(values, _.constant(undefined)),
actual = _.at(array, values);
deepEqual(actual, expected);
});
test('should return an empty array when no keys are provided', 1, function() {
deepEqual(_.at(['a', 'b', 'c']), []);
});