MCPcopy Index your code
hub / github.com/immerjs/immer / run

Function run

__tests__/patch.js:1170–1196  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1168
1169describe("#468", () => {
1170 function run() {
1171 const item = {id: 1}
1172 const state = [item]
1173 const [nextState, patches] = produceWithPatches(state, draft => {
1174 draft[0].id = 2
1175 draft[1] = item
1176 })
1177
1178 expect(nextState).toEqual([{id: 2}, {id: 1}])
1179 expect(patches).toEqual([
1180 {
1181 op: "replace",
1182 path: [0, "id"],
1183 value: 2
1184 },
1185 {
1186 op: "add",
1187 path: [1],
1188 value: {
1189 id: 1
1190 }
1191 }
1192 ])
1193
1194 const final = applyPatches(state, patches)
1195 expect(final).toEqual(nextState)
1196 }
1197
1198 test("proxy", () => {
1199 run()

Callers 1

patch.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected