mirror of
https://github.com/toss/es-toolkit.git
synced 2025-01-08 17:31:36 +03:00
test(omit) : Add test cases for omit (#42)
This commit is contained in:
parent
e7a04cd1d8
commit
c7dd4a38c9
@ -7,4 +7,23 @@ describe('omit', () => {
|
|||||||
|
|
||||||
expect(omit(object, ['foo', 'bar'])).toEqual({ baz: 3 });
|
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 });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user