mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 09:47:48 +00:00
wip: code formatting nits continued
This commit is contained in:
28
test/last.spec.js
Normal file
28
test/last.spec.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import lodashStable from 'lodash';
|
||||
import last from '../src/last';
|
||||
|
||||
describe('last', () => {
|
||||
const array = [1, 2, 3, 4];
|
||||
|
||||
it('should return the last element', () => {
|
||||
expect(last(array)).toBe(4);
|
||||
});
|
||||
|
||||
it('should return `undefined` when querying empty arrays', () => {
|
||||
const array = [];
|
||||
array['-1'] = 1;
|
||||
|
||||
expect(last([])).toBe(undefined);
|
||||
});
|
||||
|
||||
it('should work as an iteratee for methods like `_.map`', () => {
|
||||
const array = [
|
||||
[1, 2, 3],
|
||||
[4, 5, 6],
|
||||
[7, 8, 9],
|
||||
];
|
||||
const actual = lodashStable.map(array, last);
|
||||
|
||||
expect(actual).toEqual([3, 6, 9]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user