Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
frankharkins committed Nov 1, 2024
1 parent 9f2a2ed commit 44f2214
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions scripts/js/lib/api/htmlToMd.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ Can be either (1) a dictionary mapping XX angle values to fidelity at that angle
// Transform code blocks
// ------------------------------------------------------------------

test("translate codeblocks to code fences with lang python", async () => {
test("translate codeblocks to code fences with default lang python", async () => {
expect(
await toMd(`
<div class='highlight-python notranslate'>
<div class='highlight-default notranslate'>
<div role='main'>
<pre><span></span><span class='n'>QiskitRuntimeService</span><span class='o'>.</span><span class='n'>backends</span><span class='p'>(</span>
<span class='n'>filters</span><span class='o'>=</span><span class='k'>lambda</span> <span class='n'>b</span><span class='p'>:</span> <span class='n'>b</span><span class='o'>.</span><span class='n'>max_shots</span> <span class='o'>&gt;</span> <span class='mi'>50000</span><span class='p'>)</span>
Expand All @@ -122,6 +122,28 @@ QiskitRuntimeService.backends(
`);
});

test("translate codeblocks to code fences with lang c", async () => {
expect(
await toMd(`
<div class='highlight-c notranslate'>
<div role='main'>
<pre><span></span><span class='n'>QiskitRuntimeService</span><span class='o'>.</span><span class='n'>backends</span><span class='p'>(</span>
<span class='n'>filters</span><span class='o'>=</span><span class='k'>lambda</span> <span class='n'>b</span><span class='p'>:</span> <span class='n'>b</span><span class='o'>.</span><span class='n'>max_shots</span> <span class='o'>&gt;</span> <span class='mi'>50000</span><span class='p'>)</span>
<span class='n'>QiskitRuntimeService</span><span class='o'>.</span><span class='n'>backends</span><span class='p'>(</span>
<span class='n'>filters</span><span class='o'>=</span><span class='k'>lambda</span> <span class='n'>x</span><span class='p'>:</span> <span class='p'>(</span><span class='s2'>&quot;rz&quot;</span> <span class='ow'>in</span> <span class='n'>x</span><span class='o'>.</span><span class='n'>basis_gates</span> <span class='p'>)</span>
</pre>
</div>
</div>
`),
).toEqual(`\`\`\`c
QiskitRuntimeService.backends(
filters=lambda b: b.max_shots > 50000)
QiskitRuntimeService.backends(
filters=lambda x: ("rz" in x.basis_gates )
\`\`\`
`);
});

// ------------------------------------------------------------------
// Transform methods and attributes
// ------------------------------------------------------------------
Expand Down

0 comments on commit 44f2214

Please sign in to comment.