How to use the prosemirror-test-builder.code 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-view / test / test-selection.js View on Github external
it("produces sensible screen coordinates in corner cases", () => {
    let view = tempEditor({doc: doc(p("one", em("two", strong("three"), img), br, code("foo")), p())})
    return new Promise(ok => {
      setTimeout(() => {
        allPositions(view.state.doc).forEach(pos => {
          let coords = view.coordsAtPos(pos)
          let found = view.posAtCoords({top: coords.top + 1, left: coords.left}).pos
          ist(found, pos)
          setSel(view, pos)
        })
        ok()
      }, 20)
    })
  })
github ProseMirror / prosemirror-model / test / test-dom.js View on Github external
it("can render marks with complex structure", () => {
    let deepEm = new DOMSerializer(serializer.nodes, Object.assign({}, serializer.marks, {
      em() { return ["em", ["i", {"data-emphasis": true}, 0]] }
    }))
    ist(deepEm.serializeNode(p(strong("foo", code("bar"), em(code("baz"))), em("quux"), "xyz"), {document}).innerHTML,
        "<strong>foo<code>bar</code></strong><em><i data-emphasis="\&quot;true\&quot;"><strong><code>baz</code></strong>quux</i></em>xyz")
  })
})
github ProseMirror / prosemirror-model / test / test-dom.js View on Github external
it("doesn't split other marks for omitted marks", () =&gt; {
    ist(noEm.serializeNode(p("foo", code("bar"), em(code("baz"), "quux"), "xyz"), {document}).innerHTML,
        "foo<code>barbaz</code>quuxxyz")
  })
github ProseMirror / prosemirror-model / test / test-dom.js View on Github external
"<ol><li><p>one</p></li><li><p>two</p></li><li><p>three<strong>!</strong></p></li></ol><p>after</p>"))

    it("can represent a blockquote",
       test(doc(blockquote(p("hello"), p("bye"))),
            "<blockquote><p>hello</p><p>bye</p></blockquote>"))

    it("can represent a nested blockquote",
       test(doc(blockquote(blockquote(blockquote(p("he said"))), p("i said"))),
            "<blockquote><blockquote><blockquote><p>he said</p></blockquote></blockquote><p>i said</p></blockquote>"))

    it("can represent headings",
       test(doc(h1("one"), h2("two"), p("text")),
            "<h1>one</h1><h2>two</h2><p>text</p>"))

    it("can represent inline code",
       test(doc(p("text and ", code("code that is ", em("emphasized"), "..."))),
            "<p>text and <code>code that is </code><em><code>emphasized</code></em><code>...</code></p>"))

    it("can represent a code block",
       test(doc(blockquote(pre("some code")), p("and")),
            "<blockquote><pre><code>some code</code></pre></blockquote><p>and</p>"))

    it("supports leaf nodes in marks",
       test(doc(p(em("hi", br, "x"))),
            "<p><em>hi<br>x</em></p>"))

    it("doesn't collapse non-breaking spaces",
       test(doc(p("\u00a0 \u00a0hello\u00a0")),
            "<p>\u00a0 \u00a0hello\u00a0</p>"))

    it("can parse marks on block nodes", () =&gt; {
      let commentSchema = new Schema({
github ProseMirror / prosemirror-transform / test / test-trans.js View on Github external
it("can add a mark in a nested node", () =&gt;
       add(doc(p("before"), blockquote(p("the variable is called <a>i<b>")), p("after")),
           schema.mark("code"),
           doc(p("before"), blockquote(p("the variable is called ", code("i"))), p("after"))))
</b></a>
github ProseMirror / prosemirror-model / test / test-node.js View on Github external
it("preserves marks", () =&gt;
       cut(doc(p("foo", em("ba<a>r", img, strong("baz"), br), "qu<b>ux", code("xyz"))),
           doc(p(em("r", img, strong("baz"), br), "qu"))))
  })</b></a>
github ProseMirror / prosemirror-view / test / test-composition.js View on Github external
it("handles composition in a multi-child mark with a cursor wrapper", () =&gt; {
    let pm = requireFocus(tempEditor({doc: doc(p("one ", em("two<a>", strong(" three"))))}))
    pm.dispatch(pm.state.tr.addStoredMark(schema.marks.code.create()))
    let emNode = pm.dom.querySelector("em")
    compose(pm, () =&gt; edit(emNode.insertBefore(document.createTextNode(""), emNode.querySelector("strong")), "o"), [
      n =&gt; edit(n, "o"),
      n =&gt; edit(n, "w")
    ], {node: true})
    ist(pm.state.doc, doc(p("one ", em("two", code("oow"), strong(" three")))), eq)
  })
</a>
github ProseMirror / prosemirror-model / test / test-node.js View on Github external
it("shows marks", () => {
      ist(doc(p("foo", em("bar", strong("quux")), code("baz"))).toString(),
          'doc(paragraph("foo", em("bar"), em(strong("quux")), code("baz")))')
    })
  })
github ProseMirror / prosemirror-model / test / test-node.js View on Github external
it("iterates over inline nodes", () =&gt;
       between(doc(p(em("x"), "f<a>oo", em("bar", img, strong("baz"), br), "quux", code("xy<b>z"))),
               "paragraph", "foo", "bar", "image", "baz", "hard_break", "quux", "xyz"))
  })</b></a>