Skip to content

Commit

Permalink
test(omit) : Add test cases for omit (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
sossost authored Jun 13, 2024
1 parent e7a04cd commit c7dd4a3
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/object/omit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,23 @@ describe('omit', () => {

expect(omit(object, ['foo', 'bar'])).toEqual({ baz: 3 });
});

it('should return an empty object if all keys are omitted', () => {
const obj = { a: 1, b: 2, c: 3 };
const result = omit(obj, ['a', 'b', 'c']);
expect(result).toEqual({});
});

it('should return the same object if no keys are omitted', () => {
const obj = { a: 1, b: 2, c: 3 };
const result = omit(obj, []);
expect(result).toEqual({ a: 1, b: 2, c: 3 });
});

it('should not affect the original object', () => {
const obj = { a: 1, b: 2, c: 3 };
const result = omit(obj, ['b']);
expect(result).toEqual({ a: 1, c: 3 });
expect(obj).toEqual({ a: 1, b: 2, c: 3 });
});
});

0 comments on commit c7dd4a3

Please sign in to comment.