mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 16:47:49 +00:00
change .grab to .at, add unlimited args or numbers or arrays and simplify function call to use values and pick
Former-commit-id: 3deb82ad9f55cd7261453a40bb0f046a5340790d
This commit is contained in:
12
test/test.js
12
test/test.js
@@ -667,23 +667,19 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.grab');
|
||||
QUnit.module('lodash.at');
|
||||
|
||||
(function() {
|
||||
test('should get items in range', function() {
|
||||
var result = _.grab(['a', 'b', 1.4, 'c', { 'foo': 'bar' }, 'd'], [0, 2, 4]);
|
||||
var result = _.at(['a', 'b', 1.4, 'c', { 'foo': 'bar' }, 'd'], [0, 2, 4]);
|
||||
deepEqual( result, ['a', 1.4, { 'foo': 'bar' } ]);
|
||||
});
|
||||
test('should work with an object for `collection`', function() {
|
||||
var result = _.grab({ 'a': 'apple', 'b': 'ball', 'c': 'count' }, ['a', 'c']);
|
||||
var result = _.at({ 'a': 'apple', 'b': 'ball', 'c': 'count' }, ['a', 'c']);
|
||||
deepEqual(result, ['apple', 'count']);
|
||||
});
|
||||
test('no list should return an empty array', function() {
|
||||
deepEqual(_.grab(['a', 'b', 'c']), [] );
|
||||
});
|
||||
test('out of range selections should return undefined', function() {
|
||||
var result = _.grab(['a', 'b', 'c'], [1, 9001]);
|
||||
deepEqual( result, ['b', undefined]);
|
||||
deepEqual(_.at(['a', 'b', 'c']), [] );
|
||||
});
|
||||
}());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user