Skip to main content
Module

x/rambda/mergeDeepRight.spec.js

Faster and smaller alternative to Ramda
Go to Latest
File
// import { mergeDeepRight } from 'ramda'import { mergeDeepRight } from './mergeDeepRight'
const slave = { name : 'evilMe', age : 10, contact : { a : 1, email : 'foo@example.com', },}const master = { age : 40, contact : { email : 'baz@example.com' }, songs : { title : 'Remains the same' },}
test('happy', () => { const result = mergeDeepRight(slave, master) const curryResult = mergeDeepRight(slave)(master) const expected = { age : 40, name : 'evilMe', contact : { a : 1, email : 'baz@example.com', }, songs : { title : 'Remains the same' }, }
expect(result).toEqual(expected) expect(curryResult).toEqual(expected)})
test('ramda compatible test 1', () => { const a = { w : 1, x : 2, y : { z : 3 }, } const b = { a : 4, b : 5, c : { d : 6 }, } const result = mergeDeepRight(a, b) const expected = { w : 1, x : 2, y : { z : 3 }, a : 4, b : 5, c : { d : 6 }, }
expect(result).toEqual(expected)})
test('ramda compatible test 2', () => { const a = { a : { b : 1, c : 2, }, y : 0, } const b = { a : { b : 3, d : 4, }, z : 0, } const result = mergeDeepRight(a, b) const expected = { a : { b : 3, c : 2, d : 4, }, y : 0, z : 0, }
expect(result).toEqual(expected)})
test('ramda compatible test 3', () => { const a = { w : 1, x : { y : 2 }, } const result = mergeDeepRight(a, { x : { y : 3 } }) const expected = { w : 1, x : { y : 3 }, } expect(result).toEqual(expected)})