diff options
Diffstat (limited to 'packages/markdown/remark/test')
-rw-r--r-- | packages/markdown/remark/test/remark-collect-images.test.js | 4 | ||||
-rw-r--r-- | packages/markdown/remark/test/shiki.test.js | 26 |
2 files changed, 19 insertions, 11 deletions
diff --git a/packages/markdown/remark/test/remark-collect-images.test.js b/packages/markdown/remark/test/remark-collect-images.test.js index 025d909aa..669bee595 100644 --- a/packages/markdown/remark/test/remark-collect-images.test.js +++ b/packages/markdown/remark/test/remark-collect-images.test.js @@ -23,7 +23,7 @@ describe('collect images', async () => { '<p>Hello <img __ASTRO_IMAGE_="{"src":"./img.png","alt":"inline image url","index":0}"></p>', ); - assert.deepEqual(Array.from(imagePaths), ['./img.png']); + assert.deepEqual(imagePaths, ['./img.png']); }); it('should add image paths from definition', async () => { @@ -37,6 +37,6 @@ describe('collect images', async () => { '<p>Hello <img __ASTRO_IMAGE_="{"src":"./img.webp","alt":"image ref","index":0}"></p>', ); - assert.deepEqual(Array.from(metadata.imagePaths), ['./img.webp']); + assert.deepEqual(metadata.imagePaths, ['./img.webp']); }); }); diff --git a/packages/markdown/remark/test/shiki.test.js b/packages/markdown/remark/test/shiki.test.js index ca17ab1d8..45582d752 100644 --- a/packages/markdown/remark/test/shiki.test.js +++ b/packages/markdown/remark/test/shiki.test.js @@ -33,16 +33,25 @@ describe('shiki syntax highlighting', () => { it('createShikiHighlighter works', async () => { const highlighter = await createShikiHighlighter(); - const html = await highlighter.highlight('const foo = "bar";', 'js'); + const html = await highlighter.codeToHtml('const foo = "bar";', 'js'); assert.match(html, /astro-code github-dark/); assert.match(html, /background-color:#24292e;color:#e1e4e8;/); }); + it('createShikiHighlighter works with codeToHast', async () => { + const highlighter = await createShikiHighlighter(); + + const hast = await highlighter.codeToHast('const foo = "bar";', 'js'); + + assert.match(hast.children[0].properties.class, /astro-code github-dark/); + assert.match(hast.children[0].properties.style, /background-color:#24292e;color:#e1e4e8;/); + }); + it('diff +/- text has user-select: none', async () => { const highlighter = await createShikiHighlighter(); - const html = await highlighter.highlight( + const html = await highlighter.codeToHtml( `\ - const foo = "bar"; + const foo = "world";`, @@ -57,7 +66,7 @@ describe('shiki syntax highlighting', () => { it('renders attributes', async () => { const highlighter = await createShikiHighlighter(); - const html = await highlighter.highlight(`foo`, 'js', { + const html = await highlighter.codeToHtml(`foo`, 'js', { attributes: { 'data-foo': 'bar', autofocus: true }, }); @@ -66,7 +75,10 @@ describe('shiki syntax highlighting', () => { }); it('supports transformers that reads meta', async () => { - const highlighter = await createShikiHighlighter({ + const highlighter = await createShikiHighlighter(); + + const html = await highlighter.codeToHtml(`foo`, 'js', { + meta: '{1,3-4}', transformers: [ { pre(node) { @@ -79,10 +91,6 @@ describe('shiki syntax highlighting', () => { ], }); - const html = await highlighter.highlight(`foo`, 'js', { - meta: '{1,3-4}', - }); - assert.match(html, /data-test="\{1,3-4\}"/); }); @@ -109,7 +117,7 @@ describe('shiki syntax highlighting', () => { }, }); - const html = await highlighter.highlight(`let test = "some string"`, 'cjs', { + const html = await highlighter.codeToHtml(`let test = "some string"`, 'cjs', { attributes: { 'data-foo': 'bar', autofocus: true }, }); |