swarm-ui: a todo switched from clear to upsert drops its prefix flag
This commit is contained in:
parent
06f3e76329
commit
fb8aa23e66
5 changed files with 34 additions and 12 deletions
|
|
@ -21,6 +21,7 @@ import {
|
|||
subtreeIds,
|
||||
withFlow,
|
||||
withoutFlow,
|
||||
withOp,
|
||||
} from "../src/pages/notifications/FlowDraft.ts";
|
||||
|
||||
const todo = (id) => ({
|
||||
|
|
@ -156,6 +157,16 @@ test("replaceNode keeps the place and the kind class", () => {
|
|||
assert.equal(replaceNode(f, todo("nope")).ok, false);
|
||||
});
|
||||
|
||||
test("withOp drops what the new op has no place for", () => {
|
||||
const clearing = { ...todo("t"), op: "clear", prefix: true, text: "" };
|
||||
const up = withOp(clearing, "upsert");
|
||||
assert.equal(up.op, "upsert");
|
||||
assert.equal(up.prefix, false, "only a clear may be a prefix");
|
||||
const back = withOp({ ...todo("t"), prefix: false }, "clear");
|
||||
assert.equal(back.text, "", "a clear carries no text");
|
||||
assert.equal(withOp(clearing, "clear").prefix, true, "kept on a clear");
|
||||
});
|
||||
|
||||
test("new ids do not collide", () => {
|
||||
const f = flow();
|
||||
assert.equal(newNodeId(f, "match"), "match1");
|
||||
|
|
|
|||
Loading…
Reference in a new issue