Skip to content

Commit

Permalink
✅ test: Updates and deletes from nested objects
Browse files Browse the repository at this point in the history
  • Loading branch information
joebobmiles committed Jul 12, 2021
1 parent 717be12 commit 09efa6c
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/patching.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,4 +345,38 @@ describe("patchStore", () =>

expect((store.getState().foo as { "bar": number, }).bar).toBe(1);
});

it("Applies updates to nested objects.", () =>
{
const store = create(() =>
({
"foo": { "bar": 2, },
}));

const update = {
"foo": {
"bar": 3,
},
};

patchStore(store, update);

expect(store.getState().foo.bar).toBe(3);
});

it("Applies deletions to nested objects.", () =>
{
const store = create(() =>
({
"foo": { "bar": 2, },
}));

const update = {
"foo": { },
};

patchStore(store, update);

expect(store.getState().foo.bar).toBeUndefined();
});
});

0 comments on commit 09efa6c

Please sign in to comment.