test(omit) : Add test cases for omit (#42)

This commit is contained in:
ynnsuis / 장윤수 2024-06-13 18:43:04 +09:00 committed by GitHub
parent e7a04cd1d8
commit c7dd4a38c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 });
});
});