Skip to content

Commit

Permalink
docs(readme): update
Browse files Browse the repository at this point in the history
  • Loading branch information
unadlib committed Aug 22, 2024
1 parent 51017f8 commit 177fbcc
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,28 @@ test('base - mutate', () => {
c: 1,
},
};
mutate(baseState, (draft) => {
const { patches, inversePatches } = mutate(baseState, (draft) => {
draft.a.c = 2;
});
expect(baseState).toEqual({ a: { c: 2 } });
expect({ patches, inversePatches }).toEqual({
patches: [
{
op: 'replace',
path: ['a', 'c'],
value: 2,
},
],
inversePatches: [
{
op: 'replace',
path: ['a', 'c'],
value: 1,
},
],
});
apply(baseState, inversePatches);
expect(baseState).toEqual({ a: { c: 1 } });
});

test('base - mutate with error', () => {
Expand Down

0 comments on commit 177fbcc

Please sign in to comment.