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

48
test/rest.spec.js Normal file
View File

@@ -0,0 +1,48 @@
import lodashStable from 'lodash';
import { slice, _ } from './utils';
describe('rest', () => {
function fn(a, b, c) {
return slice.call(arguments);
}
it('should apply a rest parameter to `func`', () => {
const rest = _.rest(fn);
expect(rest(1, 2, 3, 4), [1, 2, [3).toEqual(4]]);
});
it('should work with `start`', () => {
const rest = _.rest(fn, 1);
expect(rest(1, 2, 3, 4), [1, [2, 3).toEqual(4]]);
});
it('should treat `start` as `0` for `NaN` or negative values', () => {
const values = [-1, NaN, 'a'];
const expected = lodashStable.map(values, lodashStable.constant([[1, 2, 3, 4]]));
const actual = lodashStable.map(values, (value) => {
const rest = _.rest(fn, value);
return rest(1, 2, 3, 4);
});
expect(actual).toEqual(expected);
});
it('should coerce `start` to an integer', () => {
const rest = _.rest(fn, 1.6);
expect(rest(1, 2, 3), [1, [2).toEqual(3]]);
});
it('should use an empty array when `start` is not reached', () => {
const rest = _.rest(fn);
expect(rest(1), [1, undefined).toEqual([]]);
});
it('should work on functions with more than three parameters', () => {
const rest = _.rest(function (a, b, c, d) {
return slice.call(arguments);
});
expect(rest(1, 2, 3, 4, 5), [1, 2, 3, [4).toEqual(5]]);
});
});