Skip to content
Myr

docs: added Map example

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Michel Weststrate · committed by Michel Weststrate · parent b6f1d40 · Browse files · 2 files+69 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+69 added−1 removed

  • tests:+32 added−0 removed
  • other:+37 added−1 removed

2 files+69 added−1 removed

modified:__tests__/readme.js+32 added
186 unmodified lines
187 ]188 ])189 })190})191192test("Producers can update Maps", () => {193 const usersById_v1 = new Map()194195 const usersById_v2 = produce(usersById_v1, draft => {196 draft.set("michel", {name: "Michel Weststrate", country: "NL"})197 })198199 const usersById_v3 = produce(usersById_v2, draft => {200 draft.get("michel").country = "UK"201 })202203 expect(usersById_v2).not.toBe(usersById_v1)204 expect(usersById_v3).not.toBe(usersById_v2)205 expect(usersById_v1).toMatchInlineSnapshot(`Map {}`)206 expect(usersById_v2).toMatchInlineSnapshot(`207 Map {208 "michel" => Object {209 "country": "NL",210 "name": "Michel Weststrate",211 },212 }213 `)214 expect(usersById_v3).toMatchInlineSnapshot(`215 Map {216 "michel" => Object {217 "country": "UK",218 "name": "Michel Weststrate",219 },220 }221 `)222})
modified:docs/complex-objects.md+37 added-1 removed