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

Function runNestedPatchScenario

__tests__/patch.js:220–239  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

218 })
219
220 function runNestedPatchScenario() {
221 let nestedPatches = []
222 const [nextState] = produceWithPatches(makeBaseState(), draft => {
223 const node = draft.children[0]
224 draft.children.splice(0, 1) // remove node from root
225
226 const group = {id: 3, children: [node], groupName: ""} // new group
227 draft.children.splice(0, 0, group) // add group to root
228
229 const [, patches] = produceWithPatches(draft, inner => {
230 const value = inner.children[0].children[0].value
231 inner.children[0].groupName = value + " Group"
232 })
233
234 nestedPatches = patches
235 applyPatches(draft, patches)
236 })
237
238 return {nextState, patches: nestedPatches}
239 }
240
241 it("#916 nested patches with moved child draft", () => {
242 const {nextState, patches} = runNestedPatchScenario()

Callers 1

patch.jsFile · 0.85

Calls 1

makeBaseStateFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…