import "jest"; import { EditorState } from "prosemirror-state"; import * as commands from "../commands"; import { UxCommand } from "../../constants"; import { Command } from "../../types"; import { uxCommands } from "../../uxCommands"; import { buildEditorState } from "../../__specs__/buildEditorState"; import "../../__specs__/expect.toMapEditorState"; function runToggleSuite(command: Command) { function test(initial: EditorState, expected: EditorState) { expect(command).toMapEditorState(initial, expected); } it("text selection", () => { test( buildEditorState(({ doc, p }) => doc(p("t{^}ex{$}t"))), buildEditorState(({ doc, p, b }) => doc(p("t", b("{^}ex{$}"), "t"))) ); }); it("empty text selection", () => { test( buildEditorState(({ doc, p }) => doc(p("t{^}ext"))), buildEditorState(({ doc, p }) => doc(p("t{^}ext")), { storedMarks: ({ b }) => [b()] }) ); }); } describe(commands.toggle.name, () => { runToggleSuite(commands.toggle); describe("via ui", () => { runToggleSuite(uxCommands[UxCommand.Bold]); }); });