object.test.ts
This file
Path
src/utils/object.test.ts
25 lines 路 625 bytes 路 TypeScript
Last changed by
feat(validator): introduce nested validation (#592)Yusuke Wadabefore adoption2776957
History of this fileTake it
1234567891011121314151617181920212223242526import { mergeObjects } from './object'
describe('mergeObject', () => { it('Should merge two objects into one object', () => { const src = { author: { name: 'superman' }, posts: [{ id: 123 }, { id: 456 }] } const dst = { author: { age: 20 }, posts: [{ title: 'JavaScript' }, { title: 'Framework' }] } const res = mergeObjects(dst, src) expect(res).toEqual({ posts: [ { id: 123, title: 'JavaScript', }, { id: 456, title: 'Framework', }, ], author: { name: 'superman', age: 20, }, }) })})