wip: migrate to bun

This commit is contained in:
jdalton
2023-09-16 14:47:50 -07:00
parent 2da024c3b4
commit 97d4a2fe19
1052 changed files with 30244 additions and 26856 deletions

54
test/indexOf.spec.ts Normal file
View File

@@ -0,0 +1,54 @@
import assert from 'node:assert';
import lodashStable from 'lodash';
import { stubZero, falsey } from './utils';
import indexOf from '../src/indexOf';
describe('indexOf', () => {
const array = [1, 2, 3, 1, 2, 3];
it('`_.indexOf` should return the index of the first matched value', () => {
assert.strictEqual(indexOf(array, 3), 2);
});
it('`_.indexOf` should work with a positive `fromIndex`', () => {
assert.strictEqual(indexOf(array, 1, 2), 3);
});
it('`_.indexOf` should work with a `fromIndex` >= `length`', () => {
const values = [6, 8, 2 ** 32, Infinity],
expected = lodashStable.map(values, lodashStable.constant([-1, -1, -1]));
const actual = lodashStable.map(values, (fromIndex) => [
indexOf(array, undefined, fromIndex),
indexOf(array, 1, fromIndex),
indexOf(array, '', fromIndex),
]);
assert.deepStrictEqual(actual, expected);
});
it('`_.indexOf` should work with a negative `fromIndex`', () => {
assert.strictEqual(indexOf(array, 2, -3), 4);
});
it('`_.indexOf` should work with a negative `fromIndex` <= `-length`', () => {
const values = [-6, -8, -Infinity],
expected = lodashStable.map(values, stubZero);
const actual = lodashStable.map(values, (fromIndex) => indexOf(array, 1, fromIndex));
assert.deepStrictEqual(actual, expected);
});
it('`_.indexOf` should treat falsey `fromIndex` values as `0`', () => {
const expected = lodashStable.map(falsey, stubZero);
const actual = lodashStable.map(falsey, (fromIndex) => indexOf(array, 1, fromIndex));
assert.deepStrictEqual(actual, expected);
});
it('`_.indexOf` should coerce `fromIndex` to an integer', () => {
assert.strictEqual(indexOf(array, 2, 1.2), 1);
});
});