@ -5,6 +5,8 @@ const getClassList = async (locator: Locator) => {
return className ? . split ( ' ' ) . filter ( Boolean ) ? ? [ ]
}
const trim = ( str? : string | null ) = > str ? . replace ( /\u200B/g , '' ) . trim ( )
beforeEach ( async ( ) = > {
await goto ( '/markdown-extensions/' )
} )
@ -63,7 +65,7 @@ describe('Table of Contents', () => {
test ( 'render toc' , async ( ) = > {
const items = page . locator ( '#table-of-contents + nav ul li' )
const count = await items . count ( )
expect ( count ) . toBe ( 27 )
expect ( count ) . toBe ( 33 )
} )
} )
@ -161,7 +163,7 @@ describe('Line Numbers', () => {
describe ( 'Import Code Snippets' , ( ) = > {
test ( 'basic' , async ( ) = > {
const lines = page . locator ( '#basic-code-snippet + div code > span' )
expect ( await lines . count ( ) ) . toBe ( 7 )
expect ( await lines . count ( ) ) . toBe ( 11 )
} )
test ( 'specify region' , async ( ) = > {
@ -214,7 +216,7 @@ describe('Code Groups', () => {
// blocks
const blocks = div . locator ( '.blocks > div' )
expect ( await blocks . nth ( 0 ) . locator ( 'code > span' ) . count ( ) ) . toBe ( 7 )
expect ( await blocks . nth ( 0 ) . locator ( 'code > span' ) . count ( ) ) . toBe ( 11 )
expect ( await getClassList ( blocks . nth ( 1 ) ) ) . toContain ( 'line-numbers-mode' )
expect ( await getClassList ( blocks . nth ( 1 ) ) ) . toContain ( 'language-ts' )
expect ( await blocks . nth ( 1 ) . locator ( 'code > span' ) . count ( ) ) . toBe ( 3 )
@ -229,12 +231,38 @@ describe('Markdown File Inclusion', () => {
const h1 = page . locator ( '#markdown-file-inclusion + h1' )
expect ( await h1 . getAttribute ( 'id' ) ) . toBe ( 'foo' )
} )
test ( 'render markdown using @' , async ( ) = > {
const h1 = page . locator ( '#markdown-at-file-inclusion + h1' )
expect ( await h1 . getAttribute ( 'id' ) ) . toBe ( 'bar' )
} )
test ( 'render markdown using nested inclusion' , async ( ) = > {
const h1 = page . locator ( '#markdown-nested-file-inclusion + h1' )
expect ( await h1 . getAttribute ( 'id' ) ) . toBe ( 'foo-1' )
} )
test ( 'support selecting range' , async ( ) = > {
const h2 = page . locator ( '#markdown-file-inclusion-with-range + h2' )
expect ( trim ( await h2 . textContent ( ) ) ) . toBe ( 'Region' )
const p = page . locator ( '#markdown-file-inclusion-with-range + h2 + p' )
expect ( trim ( await p . textContent ( ) ) ) . toBe ( 'This is a region' )
} )
test ( 'support selecting range without specifying start' , async ( ) = > {
const p = page . locator (
'#markdown-file-inclusion-with-range-without-start ~ p'
)
expect ( trim ( await p . nth ( 0 ) . textContent ( ) ) ) . toBe ( 'This is before region' )
expect ( trim ( await p . nth ( 1 ) . textContent ( ) ) ) . toBe ( 'This is a region' )
} )
test ( 'support selecting range without specifying end' , async ( ) = > {
const p = page . locator (
'#markdown-file-inclusion-with-range-without-end ~ p'
)
expect ( trim ( await p . nth ( 0 ) . textContent ( ) ) ) . toBe ( 'This is a region' )
expect ( trim ( await p . nth ( 1 ) . textContent ( ) ) ) . toBe ( 'This is after region' )
} )
} )