mirror of
https://github.com/outline/outline.git
synced 2026-12-06 11:12:32 +03:00
* 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
33 lines
1.0 KiB
TypeScript
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");
|
|
});
|
|
});
|