Files
outline/shared/editor/lib/chainTransactions.test.ts
T
Tom Moor ce845b89e9 fix: Correct logic errors in shared utilities (#14904)
* fix: Correct logic errors in shared utilities

* fix: Restore per-column cells in getCellsInRow and convert every attachment url

The g flag made the attachment regex skip every second match, and removing
duplicate cells broke callers that index getCellsInRow by column.

* test: Cover uppercase attachment URLs

* revert: Remove uncertain fixes
2026-12-05 12:48:21 -05:00

33 lines
1.0 KiB
TypeScript

import type { Command } from "prosemirror-state";
import { createEditorStateWithSelection, doc, p } from "@shared/test/editor";
import { chainTransactions } from "./chainTransactions";
describe("chainTransactions", () => {
it("can be invoked more than once without losing commands", () => {
const cmd1: Command = (state, dispatch) => {
dispatch?.(state.tr.insertText("a", state.selection.from));
return true;
};
const cmd2: Command = (state, dispatch) => {
dispatch?.(state.tr.insertText("b", state.selection.from));
return true;
};
const chained = chainTransactions(cmd1, cmd2);
const runOnce = () => {
const state = createEditorStateWithSelection(doc([p("x")]), 1);
let next = state;
chained(state, (tr) => {
next = next.apply(tr);
});
return next.doc.textContent;
};
const first = runOnce();
const second = runOnce();
expect(first).toBe(second);
expect(first).toContain("a");
expect(first).toContain("b");
});
});