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
feat(validator): introduce nested validation (#592)Yusuke Wadabefore adoption2776957
lines 1–25why, one step back1import { mergeObjects } from './object'23describe('mergeObject', () => {4 it('Should merge two objects into one object', () => {5 const src = { author: { name: 'superman' }, posts: [{ id: 123 }, { id: 456 }] }6 const dst = { author: { age: 20 }, posts: [{ title: 'JavaScript' }, { title: 'Framework' }] }7 const res = mergeObjects(dst, src)8 expect(res).toEqual({9 posts: [10 {11 id: 123,12 title: 'JavaScript',13 },14 {15 id: 456,16 title: 'Framework',17 },18 ],19 author: {20 name: 'superman',21 age: 20,22 },23 })24 })25})