wip: code formatting nits continued

This commit is contained in:
jdalton
2023-09-16 22:59:56 -07:00
parent 0b28b7f7b6
commit b5c59317ea
421 changed files with 7354 additions and 9005 deletions

37
test/dropRight.spec.js Normal file
View File

@@ -0,0 +1,37 @@
import lodashStable from 'lodash';
import { falsey } from './utils';
import dropRight from '../src/dropRight';
describe('dropRight', () => {
const array = [1, 2, 3];
it('should drop the last two elements', () => {
expect(dropRight(array, 2)).toEqual([1]);
});
it('should treat falsey `n` values, except `undefined`, as `0`', () => {
const expected = lodashStable.map(falsey, (value) =>
value === undefined ? [1, 2] : array,
);
const actual = lodashStable.map(falsey, (n) => dropRight(array, n));
expect(actual).toEqual(expected);
});
it('should return all elements when `n` < `1`', () => {
lodashStable.each([0, -1, -Infinity], (n) => {
expect(dropRight(array, n)).toEqual(array);
});
});
it('should return an empty array when `n` >= `length`', () => {
lodashStable.each([3, 4, 2 ** 32, Infinity], (n) => {
expect(dropRight(array, n)).toEqual([]);
});
});
it('should coerce `n` to an integer', () => {
expect(dropRight(array, 1.6)).toEqual([1, 2]);
});
});