diff --git a/docs/reference/functions/mergeform.md b/docs/reference/functions/mergeform.md index 395c40c15..16c15c5f6 100644 --- a/docs/reference/functions/mergeform.md +++ b/docs/reference/functions/mergeform.md @@ -27,4 +27,4 @@ function mergeForm(baseForm, state): FormApi { expect(a).toStrictEqual({ a: undefined }) }) - test('Should merge two object by merging arrays', () => { - const a = { a: [1] } - const b = { a: [2] } - mutateMergeDeep(a, b) - expect(a).toStrictEqual({ a: [1, 2] }) + test('Should merge two object by overriding arrays', () => { + const target = { a: [1] } + const source = { a: [2] } + mutateMergeDeep(target, source) + expect(target).toStrictEqual({ a: [2] }) + }) + + test('Should merge add array element when it does not exist in target', () => { + const target = { a: [] } + const source = { a: [2] } + mutateMergeDeep(target, source) + expect(target).toStrictEqual({ a: [2] }) + }) + + test('Should override the target array if source is undefined', () => { + const target = { a: [2] } + const source = { a: undefined } + mutateMergeDeep(target, source) + expect(target).toStrictEqual({ a: undefined }) + }) + + test('Should merge update array element when it does not exist in source', () => { + const target = { a: [2] } + const source = { a: [] } + mutateMergeDeep(target, source) + expect(target).toStrictEqual({ a: [] }) }) test('Should merge two deeply nested objects', () => {