Sha256: 9dae0671cd97cc7a569b981b04ee26e8b810f4c83e2a807f657ca76e6f70c907
Contents?: true
Size: 1.23 KB
Versions: 3
Compression:
Stored size: 1.23 KB
Contents
import { createBasicEditor, updateContent } from "../helpers"; import CharacterCount from "../../extensions/character_count"; describe("CharacterCount", () => { let editor = null; let editorElement = null; const setupEditor = (extension) => { editor = createBasicEditor({ extensions: [extension] }) editorElement = editor.view.dom; }; beforeEach(() => { document.body.innerHTML = ""; }); describe("with no options", () => { beforeEach(() => setupEditor(CharacterCount)); it("counts the characters", async () => { editorElement.focus(); await updateContent(editorElement, "Hello, world!"); expect(editor.storage.characterCount.characters()).toBe(13); }); }); describe("with a defined character limit", () => { beforeEach(() => setupEditor(CharacterCount.configure({ limit: 13 }))); // See: https://github.com/ueberdosis/tiptap/issues/3721 it("does not allow new paragraphs after reaching the characters limit", async () => { editorElement.focus(); await updateContent(editorElement, "Hello, world!"); editorElement.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter" })); expect(editor.getHTML()).toEqual("<p>Hello, world!</p>"); }); }); });
Version data entries
3 entries across 3 versions & 1 rubygems