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/constant.spec.js Normal file
View File

@@ -0,0 +1,37 @@
import lodashStable from 'lodash';
import { empties, _, falsey, stubTrue } from './utils';
describe('constant', () => {
it('should create a function that returns `value`', () => {
const object = { a: 1 };
const values = Array(2).concat(empties, true, 1, 'a');
const constant = _.constant(object);
const results = lodashStable.map(values, (value, index) => {
if (index < 2) {
return index ? constant.call({}) : constant();
}
return constant(value);
});
expect(lodashStable.every(results, (result) => result === object));
});
it('should work with falsey values', () => {
const expected = lodashStable.map(falsey, stubTrue);
const actual = lodashStable.map(falsey, (value, index) => {
const constant = index ? _.constant(value) : _.constant();
const result = constant();
return result === value || (result !== result && value !== value);
});
expect(actual).toEqual(expected);
});
it('should return a wrapped value when chaining', () => {
const wrapped = _(true).constant();
expect(wrapped instanceof _);
});
});