mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-28 12:05:41 +03:00
test: Update some test code
This commit is contained in:
parent
11028f76be
commit
1135f67c06
32
src/compat/array/initial.spec.ts
Normal file
32
src/compat/array/initial.spec.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { initial } from '../../array/initial';
|
||||
|
||||
/**
|
||||
* @see https://github.com/lodash/lodash/blob/6a2cc1dfcf7634fea70d1bc5bd22db453df67b42/test/initial.spec.js#L1
|
||||
*/
|
||||
describe('initial', () => {
|
||||
const array = [1, 2, 3];
|
||||
|
||||
it('should exclude last element', () => {
|
||||
expect(initial(array)).toEqual([1, 2]);
|
||||
});
|
||||
|
||||
it('should return an empty when querying empty arrays', () => {
|
||||
expect(initial([])).toEqual([]);
|
||||
});
|
||||
|
||||
it('should work as an iteratee for methods like `map`', () => {
|
||||
const array = [
|
||||
[1, 2, 3],
|
||||
[4, 5, 6],
|
||||
[7, 8, 9],
|
||||
];
|
||||
const actual = array.map(initial);
|
||||
|
||||
expect(actual).toEqual([
|
||||
[1, 2],
|
||||
[4, 5],
|
||||
[7, 8],
|
||||
]);
|
||||
});
|
||||
});
|
26
src/compat/array/without.spec.ts
Normal file
26
src/compat/array/without.spec.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { without } from '../../array/without';
|
||||
|
||||
/**
|
||||
* @see https://github.com/lodash/lodash/blob/6a2cc1dfcf7634fea70d1bc5bd22db453df67b42/test/without.spec.js#L1
|
||||
*/
|
||||
describe('without', () => {
|
||||
it('should return the difference of values', () => {
|
||||
const actual = without([2, 1, 2, 3], 1, 2);
|
||||
expect(actual).toEqual([3]);
|
||||
});
|
||||
|
||||
it('should use strict equality to determine the values to reject', () => {
|
||||
const object1 = { a: 1 };
|
||||
const object2 = { b: 2 };
|
||||
const array = [object1, object2];
|
||||
|
||||
expect(without(array, { a: 1 })).toEqual(array);
|
||||
expect(without(array, object1)).toEqual([object2]);
|
||||
});
|
||||
|
||||
it('should remove all occurrences of each value from an array', () => {
|
||||
const array = [1, 2, 3, 1, 2, 3];
|
||||
expect(without(array, 1, 2)).toEqual([3, 3]);
|
||||
});
|
||||
});
|
@ -5,7 +5,6 @@ import { isEqual } from "es-toolkit/compat";
|
||||
import { args } from "../_internal/args";
|
||||
import { arrayViews } from "../_internal/arrayViews";
|
||||
|
||||
|
||||
describe('isEqual', () => {
|
||||
const symbol1 = Symbol ? Symbol('a') : true;
|
||||
const symbol2 = Symbol ? Symbol('b') : false;
|
||||
|
Loading…
Reference in New Issue
Block a user