deno.land / x / rambda@v9.1.1 / source / mergeDeepRight.spec.js

mergeDeepRight.spec.js
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import { mergeDeepRight } from './mergeDeepRight.js'
const student = { name : 'foo', age : 10, contact : { a : 1, email : 'foo@example.com', },}const teacher = { age : 40, contact : { email : 'baz@example.com' }, songs : { title : 'Remains the same' },}
test('when merging object with lists inside them', () => { const a = { a : [ 1, 2, 3 ], b : [ 4, 5, 6 ], } const b = { a : [ 7, 8, 9 ], b : [ 10, 11, 12 ], } const result = mergeDeepRight(a, b) const expected = { a : [ 7, 8, 9 ], b : [ 10, 11, 12 ], } expect(result).toEqual(expected)})
test('happy', () => { const result = mergeDeepRight(student, teacher) const curryResult = mergeDeepRight(student)(teacher) const expected = { age : 40, name : 'foo', contact : { a : 1, email : 'baz@example.com', }, songs : { title : 'Remains the same' }, }
expect(result).toEqual(expected) expect(curryResult).toEqual(expected)})
test('issue 650', () => { expect(Object.keys(mergeDeepRight({ a : () => {} }, { b : () => {} }))).toEqual([ 'a', 'b', ])})
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)})
test('functions are not discarded', () => { const obj = { foo : () => {} } expect(typeof mergeDeepRight(obj, {}).foo).toBe('function')})
rambda

Version Info

Tagged at
2 months ago