Skip to content

Commit

Permalink
Add string variant of first test
Browse files Browse the repository at this point in the history
  • Loading branch information
chrissantamaria committed Jun 28, 2021
1 parent 0f35370 commit faf9464
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions __tests__/map-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ function runBaseTest(name, useProxies, autoFreeze, useListener) {
expect(mapType1).toBe(mapType2)
})

test("#819 - Set maintains order when adding", () => {
const objs = [
test("#819 - Set with object maintains order when adding object", () => {
const items = [
{
id: "a"
},
Expand All @@ -306,12 +306,29 @@ function runBaseTest(name, useProxies, autoFreeze, useListener) {
}
]

const set = new Set([objs[0]])
const set = new Set([items[0]])
const newSet = produce(set, draft => {
draft.add(objs[1])
draft.add(items[1])
})

expect(Array.from(newSet)).toEqual([objs[0], objs[1]])
expect(Array.from(newSet)).toEqual([items[0], items[1]])
})

// More specific varaint of above test covering case of adding non-object item
test("#819 - Set with object maintains order when adding string", () => {
const items = [
{
id: "a"
},
"b"
]

const set = new Set([items[0]])
const newSet = produce(set, draft => {
draft.add(items[1])
})

expect(Array.from(newSet)).toEqual([items[0], items[1]])
})
})
}

0 comments on commit faf9464

Please # to comment.