Skip to content

Commit

Permalink
Add tests for sets and maps.
Browse files Browse the repository at this point in the history
Adds standalone and nested tests for sets and maps.

Related to: #17

Signed-off-by: JK <u.sslooky@gmail.com>
  • Loading branch information
JammSpread committed Mar 13, 2021
1 parent 8a17c90 commit cdd179d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,24 @@ function types (clone, label) {
deepEqual(Array.from(cloned.view2), [input2, input3], 'cloned value content is correct')
deepEqual(Array.from(cloned.view3), [input1, 0, input2, input3], 'cloned value content is correct')
})
test(`${label} - maps`, async ({ same, isNot }) => {
const map = new Map([['a', 1]])
same(Array.from(clone(map)), [['a', 1]])
isNot(clone(map), map)
})
test(`${label} - sets`, async ({ same, isNot }) => {
const set = new Set([1])
same(Array.from(clone(set)), [1])
isNot(clone(set), set)
})
test(`${label} - nested maps`, async ({ same, isNot }) => {
const data = { m: new Map([['a', 1]]) }
same(Array.from(clone(data).m), [['a', 1]])
isNot(clone(data).m, data.m)
})
test(`${label} - nested sets`, async ({ same, isNot }) => {
const data = { s: new Set([1]) }
same(Array.from(clone(data).s), [1])
isNot(clone(data).s, data.s)
})
}

0 comments on commit cdd179d

Please # to comment.