-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: test highlighted lines in code blocks
- Loading branch information
Showing
2 changed files
with
26 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { expect, it } from 'vitest' | ||
import { parseMarkdown } from '../utils/parser' | ||
|
||
const md = ` | ||
\`\`\`ts {2,3} | ||
class C { | ||
private name: string = "foo" | ||
private age: number = 18 | ||
} | ||
\`\`\` | ||
`.trim() | ||
|
||
it('Highlighted code block', async () => { | ||
const { body } = await parseMarkdown(md, { | ||
highlight: { | ||
theme: 'github-dark' | ||
} | ||
}) | ||
expect(body).toHaveProperty('type', 'root') | ||
expect(body.children).toHaveLength(2) | ||
expect((body.children[0] as any).props?.highlights).toEqual([2,3]) | ||
expect((body.children[0] as any).children[0].children[1].props).haveOwnProperty('class', 'line highlight') | ||
expect((body.children[0] as any).children[0].children[2].props).haveOwnProperty('class', 'line highlight') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters