Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
smirea committed Nov 17, 2020
1 parent 3892e4d commit 462f506
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions __tests__/patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -1147,3 +1147,24 @@ test("#676 patching Date objects", () => {
)
expect(rebuilt.date).toEqual(new Date(2020, 10, 10, 8, 8, 8, 3))
})

test("#648 assigning object to itself should not change patches", () => {
const input = {
obj: {
value: 200
}
}

const [nextState, patches] = produceWithPatches(input, draft => {
draft.obj.value = 1
draft.obj = draft.obj
})

expect(patches).toEqual([
{
op: "replace",
path: ["obj", "value"],
value: 1
}
])
})

0 comments on commit 462f506

Please # to comment.