pr(#1461): addressed review comments

This commit is contained in:
Anoop M D 2024-01-28 18:12:17 +05:30
parent f2a187d5fe
commit 2a6bfabc30

View File

@ -36,4 +36,16 @@ describe('flattenObject', () => {
const output = flattenObject(input); const output = flattenObject(input);
expect(output).toEqual({}); expect(output).toEqual({});
}); });
it('should handle an object with duplicate keys - dot notation used to define the last duplicate key', () => {
const input = { a: { b: 2 }, 'a.b': 1 };
const output = flattenObject(input);
expect(output).toEqual({ 'a.b': 1 });
});
it('should handle an object with duplicate keys - inner object used to define the last duplicate key', () => {
const input = { 'a.b': 1, a: { b: 2 } };
const output = flattenObject(input);
expect(output).toEqual({ 'a.b': 2 });
});
}); });