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

mergeRight.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
import { mergeRight } from './mergeRight.js'
const obj = { foo : 1, bar : 2,}
test('happy', () => { expect(mergeRight(obj, { bar : 20 })).toEqual({ foo : 1, bar : 20, })})
test('curry', () => { expect(mergeRight(obj)({ baz : 3 })).toEqual({ foo : 1, bar : 2, baz : 3, })})
/** * https://github.com/selfrefactor/rambda/issues/77 */test('when undefined or null instead of object', () => { expect(mergeRight(null, undefined)).toEqual({}) expect(mergeRight(obj, null)).toEqual(obj) expect(mergeRight(obj, undefined)).toEqual(obj) expect(mergeRight(undefined, obj)).toEqual(obj)})
test('with function inside object', () => { const result = mergeRight({ a : 1 }, { b : () => 1 }) expect(typeof result.b).toBe('function')})
describe('acts as if nil values are simply empty objects', () => { const a = { w : 1, x : 2, } const b = { w : 100, y : 3, z : 4, }
it('if the first object is nil', () => { expect(mergeRight(null, b)).toEqual(b) })
it('if the second object is nil', () => { expect(mergeRight(a, undefined)).toEqual(a) })
it('if both objects are nil', () => { expect(mergeRight(null, undefined)).toEqual({}) })})
rambda

Version Info

Tagged at
2 months ago