Skip to content

Commit

Permalink
test: JSX expressions, components, syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
bholmesdev committed Jul 21, 2022
1 parent 207a1fa commit 547687c
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions packages/astro/test/astro-markdown-md-mode.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { expect } from 'chai';
import * as cheerio from 'cheerio';
import { loadFixture, fixLineEndings } from './test-utils.js';

describe('Astro Markdown - plain MD mode', () => {
let fixture;

before(async () => {
fixture = await loadFixture({
root: './fixtures/astro-markdown/',
markdown: {
mode: 'md',
},
});
await fixture.build();
});

it('Leaves JSX expressions unprocessed', async () => {
const html = await fixture.readFile('/jsx-expressions/index.html');
const $ = cheerio.load(html);

expect($('h2').html()).to.equal('{frontmatter.title}');
});

it('Leaves JSX components un-transformed', async () => {
const html = await fixture.readFile('/children/index.html');

expect(html).to.include('<textblock title="Hello world!" nopadding="">');
});

describe('syntax highlighting', async () => {
it('handles Shiki', async () => {
const html = await fixture.readFile('/code-in-md/index.html');
const $ = cheerio.load(html);

expect($('pre.astro-code').length).to.not.equal(0);
});

it('handles Prism', async () => {
fixture = await loadFixture({
root: './fixtures/astro-markdown/',
markdown: {
syntaxHighlight: 'prism',
mode: 'md',
},
});
await fixture.build();

const html = await fixture.readFile('/code-in-md/index.html');
const $ = cheerio.load(html);

expect($('pre.language-html').length).to.not.equal(0);
});
});
});

0 comments on commit 547687c

Please sign in to comment.