Skip to content

Commit

Permalink
test: improve coverage (#815)
Browse files Browse the repository at this point in the history
  • Loading branch information
D-Sketon authored Nov 12, 2024
1 parent 674a795 commit aac6974
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/compat/array/dropRight.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,8 @@ describe('dropRight', () => {
it('should work as an iteratee for methods like `_.map`', () => {
expect([[1, 2], [3, 4], [5]].map(dropRight)).toEqual([[1], [3], []]);
});

it('should support default itemsCount', () => {
expect(dropRight([1, 2, 3, 4, 5])).toEqual([1, 2, 3, 4]);
});
});
8 changes: 8 additions & 0 deletions src/compat/array/every.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,12 @@ describe('every', () => {
expect(every('123', stubFalse)).toBe(false);
expect(every(args, stubFalse)).toBe(false);
});
it('should support property-value pair', () => {
const objects = [
{ a: 0, b: 0 },
{ a: 0, b: 1 },
];
expect(every(objects, ['a', 0])).toBe(true);
expect(every(objects, ['b', 1])).toBe(false);
});
});
4 changes: 4 additions & 0 deletions src/compat/array/intersection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,8 @@ describe('intersection', () => {
expect(intersection(null, array, null, [2, 3])).toEqual([]);
expect(intersection(array, null, args, null)).toEqual([]);
});

it('should return an empty array when there are no arguments', () => {
expect(intersection()).toEqual([]);
});
});
5 changes: 5 additions & 0 deletions src/compat/array/zipObjectDeep.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,9 @@ describe('zipObject', () => {
expect(zipObjectDeep(['a'], { 0: 1, length: 1 })).toEqual({ a: 1 });
expect(zipObjectDeep(['a', 'b'], '12')).toEqual({ a: '1', b: '2' });
});

it('should treat values as empty arrays when keys are not array-like', () => {
// @ts-expect-error - invalid argument
expect(zipObjectDeep([1, 2, 3], undefined)).toEqual({ 1: undefined, 2: undefined, 3: undefined });
});
});
11 changes: 11 additions & 0 deletions src/object/mergeWith.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ describe('mergeWith', () => {
});

expect(result2).toEqual({ a: [1, 3], b: [2, 4] });

const target3 = { a: { x: 1, y: 1 }, b: [2] };
const source3 = { a: { x: 2, y: 3 }, b: [4] };

const result3 = mergeWith(target3, source3, (objValue, srcValue) => {
if (objValue.x && srcValue.x) {
return objValue.x + srcValue.x;
}
});

expect(result3).toEqual({ a: 3, b: [4] });
});

it('should use custom merge function for nested objects', () => {
Expand Down

0 comments on commit aac6974

Please sign in to comment.