-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
39 lines (31 loc) · 945 Bytes
/
test.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
const test = require('tape')
const extend = require('./')
test('extend(map, ...maps) - simple', (t) => {
const map = new Map()
const maps = [
new Map(Object.entries({ hello: 'world' })),
new Map(Object.entries({ goodbye: 'moon' })),
null, // ignored input
undefined, // ignored input
NaN, // ignored input
function() {}, // ignored input
Object.entries({ goodbye: 'sun' })
]
extend(map, ...maps)
t.equal('world', map.get('hello'))
t.equal('sun', map.get('goodbye'))
t.end()
})
test('extend(map, ...maps) - merge', (t) => {
const map = new Map()
const maps = [
{ b: { value: 'unchanged' } },
Object.entries({ a: { nested: 'value', sibling: 'unchanged' } }),
Object.entries({ a: { nested: 'changed' } }),
]
extend(true, map, ...maps)
t.equal('unchanged', map.get('b').value)
t.equal('unchanged', map.get('a').sibling)
t.equal('changed', map.get('a').nested)
t.end()
})