Skip to content

Commit

Permalink
for all tests that check invertible=true, also check invertible=false
Browse files Browse the repository at this point in the history
because this was requested by @tomalec in #228 (comment)
  • Loading branch information
warpech committed Jul 9, 2019
1 parent c6e963f commit fe85212
Show file tree
Hide file tree
Showing 2 changed files with 443 additions and 524 deletions.
12 changes: 9 additions & 3 deletions src/duplex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,23 @@ function _generate(mirror, obj, patches, path, invertible) {
else {
if (oldVal !== newVal) {
changed = true;
if (invertible) patches.push({ op: "test", path: path + "/" + escapePathComponent(key), value: _deepClone(oldVal) });
if (invertible) {
patches.push({ op: "test", path: path + "/" + escapePathComponent(key), value: _deepClone(oldVal) });
}
patches.push({ op: "replace", path: path + "/" + escapePathComponent(key), value: _deepClone(newVal) });
}
}
}
else if(Array.isArray(mirror) === Array.isArray(obj)) {
if (invertible) patches.push({ op: "test", path: path + "/" + escapePathComponent(key), value: _deepClone(oldVal) })
if (invertible) {
patches.push({ op: "test", path: path + "/" + escapePathComponent(key), value: _deepClone(oldVal) });
}
patches.push({ op: "remove", path: path + "/" + escapePathComponent(key) });
deleted = true; // property has been deleted
} else {
if (invertible) patches.push({ op: "test", path, value: mirror });
if (invertible) {
patches.push({ op: "test", path, value: mirror });
}
patches.push({ op: "replace", path, value: obj });
changed = true;
}
Expand Down

0 comments on commit fe85212

Please sign in to comment.