How to use the prosemirror-test-builder.p function in prosemirror-test-builder

To help you get started, we’ve selected a few prosemirror-test-builder examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ProseMirror / prosemirror-model / test / test-slice.js View on Github external
it("preserves styles started after cut", () =>
       t(doc(p("a ", em("sentence"), " wi<a>th ", em("text"), " in it")),
         doc(p("th ", em("text"), " in it")), 1, 0))
</a>
github ProseMirror / prosemirror-view / test / test-draw-decoration.js View on Github external
it("draws multiple widgets", () => {
    let view = tempEditor({doc: doc(p("foobar")),
                           plugins: [decoPlugin(["1-widget", "4-widget", "7-widget"])]})
    let found = view.dom.querySelectorAll("button")
    ist(found.length, 3)
    ist(found[0].nextSibling.textContent, "foo")
    ist(found[1].nextSibling.textContent, "bar")
    ist(found[2].previousSibling.textContent, "bar")
  })
github ProseMirror / prosemirror-view / test / test-selection.js View on Github external
it("can go back and forth between screen coords and document positions", () => {
    let view = tempEditor({doc: doc(p("one"), blockquote(p("two"), p("three")))})
    ;[1, 2, 4, 7, 14, 15].forEach(pos => {
      let coords = view.coordsAtPos(pos)
      let found = view.posAtCoords({top: coords.top + 1, left: coords.left}).pos
      ist(found, pos)
    })
  })
github ProseMirror / prosemirror-commands / test / test-commands.js View on Github external
it("deletes a leaf node after the current block", () =&gt;
     apply(doc(p("foo<a>"), hr, p("bar")), joinForward, doc(p("foo"), p("bar"))))
</a>
github ProseMirror / prosemirror-transform / test / test-trans.js View on Github external
it("can change a wrapped block", () =&gt;
       type(doc(blockquote(p("one<a>"), p("two<b>"))),
            doc(blockquote(h1("one</b></a><b><a>"), h1("two<b>"))),
            "heading", {level: 1}))
</b></a></b>
github ProseMirror / prosemirror-commands / test / test-commands.js View on Github external
it("moves a block into an adjacent wrapper", () =&gt;
     apply(doc(blockquote(p("hi")), p("<a>there")), joinBackward,
           doc(blockquote(p("hi"), p("there")))))
</a>
github ProseMirror / prosemirror-model / test / test-dom.js View on Github external
it("finds a valid place for invalid content",
       recover("<ul><li>hi</li><p>whoah</p><li>again</li></ul>",
               doc(ul(li(p("hi")), li(p("whoah")), li(p("again"))))))

    it("moves nodes up when they don't fit the current context",
       recover("<div>hello<hr>bye</div>",
               doc(p("hello"), hr, p("bye"))))

    it("doesn't ignore whitespace-only text nodes",
       recover("<p><em>one</em> <strong>two</strong></p>",
               doc(p(em("one"), " ", strong("two")))))

    it("can handle stray tab characters",
       recover("<p> <b>	</b></p>",
               doc(p())))

    it("normalizes random spaces",
       recover("<p><b>1 </b>  </p>",
               doc(p(strong("1")))))

    it("can parse an empty code block",
       recover("<pre></pre>",
               doc(pre())))

    it("preserves trailing space in a code block",
       recover("<pre>foo\n</pre>",
               doc(pre("foo\n"))))

    it("normalizes newlines when preserving whitespace",
       recover("<p>foo  bar\nbaz</p>",
              doc(p("foo  bar baz")), {preserveWhitespace: true}))
github ProseMirror / prosemirror-view / test / test-domchange.js View on Github external
it("doesn't treat a placeholder BR as real content", () =&gt; {
    let view = tempEditor({doc: doc(p("i<a>"))})
    view.dom.querySelector("p").innerHTML = "<br>"
    flush(view)
    ist(view.state.doc, doc(p()), eq)
  })
</a>
github ProseMirror / prosemirror-model / test / test-diff.js View on Github external
it("notices when the second doc is shorter", () =&gt;
       end(doc(p("oops"), "<a>", p("a", em("b")), p("hello"), blockquote(h1("bye"))),
           doc(p("a", em("b")), p("hello"), blockquote(h1("bye")))))
</a>
github ProseMirror / prosemirror-view / test / test-composition.js View on Github external
it("works inside highlighted text", () => {
    let pm = requireFocus(tempEditor({doc: doc(p("one two")), plugins: [wordHighlighter]}))
    compose(pm, () => edit(findTextNode(pm.dom, "one"), "x"), [
      n => edit(n, "y"),
      n => edit(n, ".")
    ])
    ist(pm.state.doc, doc(p("onexy. two")), eq)
  })