Sha256: 4e18b427ff5530e66b9cb9b5f72075611abba91e2f37e50a948ec5bc8310679a
Contents?: true
Size: 1.26 KB
Versions: 15
Compression:
Stored size: 1.26 KB
Contents
import { createBasicEditor, updateContent } from "src/decidim/editor/test/helpers"; import CharacterCount from "src/decidim/editor/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
15 entries across 15 versions & 1 rubygems