test(plugin-md-power): add python-repl unit test

This commit is contained in:
pengzhanbo 2025-06-06 21:33:11 +08:00
parent 1f89d7f515
commit 1dcd46c9c0
2 changed files with 64 additions and 0 deletions

View File

@ -17,6 +17,14 @@ exports[`langReplPlugin > should work with custom options 1`] = `
</code></pre></div></code></pre> </code></pre></div></code></pre>
</CodeRepl><CodeRepl editable title="title"><pre><code class="language-rust"><div class="language-rust"><pre><code>const a = 1 </CodeRepl><CodeRepl editable title="title"><pre><code class="language-rust"><div class="language-rust"><pre><code>const a = 1
</code></pre></div></code></pre> </code></pre></div></code></pre>
</CodeRepl><CodeRepl title="python playground"><pre><code class="language-python"><div class="language-python"><pre><code>hello_world()
</code></pre></div></code></pre>
</CodeRepl><CodeRepl editable title="python playground"><pre><code class="language-python"><div class="language-python"><pre><code>hello_world()
</code></pre></div></code></pre>
</CodeRepl><CodeRepl title="title"><pre><code class="language-python"><div class="language-python"><pre><code>hello_world()
</code></pre></div></code></pre>
</CodeRepl><CodeRepl editable title="title"><pre><code class="language-python"><div class="language-python"><pre><code>hello_world()
</code></pre></div></code></pre>
</CodeRepl>" </CodeRepl>"
`; `;
@ -31,6 +39,9 @@ exports[`langReplPlugin > should work with custom options 2`] = `
}, },
"rust": { "rust": {
"language": "rust" "language": "rust"
},
"python": {
"language": "python"
} }
}, },
"theme": { "theme": {
@ -61,6 +72,14 @@ exports[`langReplPlugin > should work with custom theme 1`] = `
</code></pre></div></code></pre> </code></pre></div></code></pre>
</CodeRepl><CodeRepl editable title="title"><pre><code class="language-rust"><div class="language-rust"><pre><code>const a = 1 </CodeRepl><CodeRepl editable title="title"><pre><code class="language-rust"><div class="language-rust"><pre><code>const a = 1
</code></pre></div></code></pre> </code></pre></div></code></pre>
</CodeRepl><CodeRepl title="python playground"><pre><code class="language-python"><div class="language-python"><pre><code>hello_world()
</code></pre></div></code></pre>
</CodeRepl><CodeRepl editable title="python playground"><pre><code class="language-python"><div class="language-python"><pre><code>hello_world()
</code></pre></div></code></pre>
</CodeRepl><CodeRepl title="title"><pre><code class="language-python"><div class="language-python"><pre><code>hello_world()
</code></pre></div></code></pre>
</CodeRepl><CodeRepl editable title="title"><pre><code class="language-python"><div class="language-python"><pre><code>hello_world()
</code></pre></div></code></pre>
</CodeRepl>" </CodeRepl>"
`; `;
@ -75,6 +94,9 @@ exports[`langReplPlugin > should work with custom theme 2`] = `
}, },
"rust": { "rust": {
"language": "rust" "language": "rust"
},
"python": {
"language": "python"
} }
} }
}" }"
@ -113,6 +135,22 @@ exports[`langReplPlugin > should work with default options 1`] = `
<pre><code class="language-rust"><div class="language-rust"><pre><code>const a = 1 <pre><code class="language-rust"><div class="language-rust"><pre><code>const a = 1
</code></pre></div></code></pre> </code></pre></div></code></pre>
<p>:::</p> <p>:::</p>
<p>::: python-repl</p>
<pre><code class="language-python"><div class="language-python"><pre><code>hello_world()
</code></pre></div></code></pre>
<p>:::</p>
<p>::: python-repl editable</p>
<pre><code class="language-python"><div class="language-python"><pre><code>hello_world()
</code></pre></div></code></pre>
<p>:::</p>
<p>::: python-repl title=&quot;title&quot;</p>
<pre><code class="language-python"><div class="language-python"><pre><code>hello_world()
</code></pre></div></code></pre>
<p>:::</p>
<p>::: python-repl editable title=&quot;title&quot;</p>
<pre><code class="language-python"><div class="language-python"><pre><code>hello_world()
</code></pre></div></code></pre>
<p>:::</p>
" "
`; `;

View File

@ -46,6 +46,7 @@ function initFs() {
[path.join(grammarsPath, 'grammars/go.json')]: '{ "language": "go" }', [path.join(grammarsPath, 'grammars/go.json')]: '{ "language": "go" }',
[path.join(grammarsPath, 'grammars/kotlin.json')]: '{ "language": "kotlin" }', [path.join(grammarsPath, 'grammars/kotlin.json')]: '{ "language": "kotlin" }',
[path.join(grammarsPath, 'grammars/rust.json')]: '{ "language": "rust" }', [path.join(grammarsPath, 'grammars/rust.json')]: '{ "language": "rust" }',
[path.join(grammarsPath, 'grammars/python.json')]: '{ "language": "python" }',
}) })
} }
@ -101,6 +102,29 @@ const a = 1
${FENCE} ${FENCE}
::: :::
::: python-repl
${FENCE}python
hello_world()
${FENCE}
:::
::: python-repl editable
${FENCE}python
hello_world()
${FENCE}
:::
::: python-repl title="title"
${FENCE}python
hello_world()
${FENCE}
:::
::: python-repl editable title="title"
${FENCE}python
hello_world()
${FENCE}
:::
` `
it('should work with default options', async () => { it('should work with default options', async () => {
initFs() initFs()
@ -117,6 +141,7 @@ ${FENCE}
go: true, go: true,
kotlin: true, kotlin: true,
rust: true, rust: true,
python: true,
}) })
expect(md.render(code)).toMatchSnapshot() expect(md.render(code)).toMatchSnapshot()
@ -130,6 +155,7 @@ ${FENCE}
go: true, go: true,
kotlin: true, kotlin: true,
rust: true, rust: true,
python: true,
theme: 'vitesse-light', theme: 'vitesse-light',
}) })