Skip to content

Commit

Permalink
chore: Add failing test Set ordering #819 (#820)
Browse files Browse the repository at this point in the history
* Add failing test

* Move test to map-set

* Add string variant of first test
  • Loading branch information
chrissantamaria committed Jan 15, 2023
1 parent b3eeb69 commit 847b662
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions __tests__/map-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,41 @@ function runBaseTest(name, useProxies, autoFreeze, useListener) {
})
expect(mapType1).toBe(mapType2)
})

test("#819 - Set with object maintains order when adding object", () => {
const items = [
{
id: "a"
},
{
id: "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]])
})

// 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]])
})
})
describe("set issues " + name, () => {
test("#819.A - maintains order when adding", () => {
Expand Down

0 comments on commit 847b662

Please sign in to comment.