0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00

chore: Migrate markdown.test.js to node:test (#10032)

This commit is contained in:
voxel!() 2024-02-08 02:23:56 -08:00 committed by GitHub
parent ec0ac4a840
commit 8555c2e3c7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,4 +1,5 @@
import { expect } from 'chai'; import assert from 'node:assert/strict';
import { describe, before, it } from 'node:test';
import * as cheerio from 'cheerio'; import * as cheerio from 'cheerio';
import { loadFixture } from './test-utils.js'; import { loadFixture } from './test-utils.js';
@ -20,57 +21,57 @@ describe('Markdown tests', () => {
it('Can load a markdown page with the `.markdown` extension', async () => { it('Can load a markdown page with the `.markdown` extension', async () => {
const html = await fixture.readFile('/dot-markdown-page/index.html'); const html = await fixture.readFile('/dot-markdown-page/index.html');
const $ = cheerio.load(html); const $ = cheerio.load(html);
expect($('h1').html()).to.equal('Page with alternative .markdown extension'); assert.strictEqual($('h1').html(), 'Page with alternative .markdown extension');
expect($('p').html()).to.equal('Hope this loads fine 🤞'); assert.strictEqual($('p').html(), 'Hope this loads fine 🤞');
}); });
it('Can load a markdown page with the `.mdwn` extension', async () => { it('Can load a markdown page with the `.mdwn` extension', async () => {
const html = await fixture.readFile('/dot-mdwn-page/index.html'); const html = await fixture.readFile('/dot-mdwn-page/index.html');
const $ = cheerio.load(html); const $ = cheerio.load(html);
expect($('h1').html()).to.equal('Page with alternative .mdwn extension'); assert.strictEqual($('h1').html(), 'Page with alternative .mdwn extension');
expect($('p').html()).to.equal('Hope this loads fine 🤞'); assert.strictEqual($('p').html(), 'Hope this loads fine 🤞');
}); });
it('Can load a markdown page with the `.mkdn` extension', async () => { it('Can load a markdown page with the `.mkdn` extension', async () => {
const html = await fixture.readFile('/dot-mkdn-page/index.html'); const html = await fixture.readFile('/dot-mkdn-page/index.html');
const $ = cheerio.load(html); const $ = cheerio.load(html);
expect($('h1').html()).to.equal('Page with alternative .mkdn extension'); assert.strictEqual($('h1').html(), 'Page with alternative .mkdn extension');
expect($('p').html()).to.equal('Hope this loads fine 🤞'); assert.strictEqual($('p').html(), 'Hope this loads fine 🤞');
}); });
it('Can load a markdown page with the `.mdown` extension', async () => { it('Can load a markdown page with the `.mdown` extension', async () => {
const html = await fixture.readFile('/dot-mdown-page/index.html'); const html = await fixture.readFile('/dot-mdown-page/index.html');
const $ = cheerio.load(html); const $ = cheerio.load(html);
expect($('h1').html()).to.equal('Page with alternative .mdown extension'); assert.strictEqual($('h1').html(), 'Page with alternative .mdown extension');
expect($('p').html()).to.equal('Hope this loads fine 🤞'); assert.strictEqual($('p').html(), 'Hope this loads fine 🤞');
}); });
it('Can load a markdown page with the `.mkd` extension', async () => { it('Can load a markdown page with the `.mkd` extension', async () => {
const html = await fixture.readFile('/dot-mkd-page/index.html'); const html = await fixture.readFile('/dot-mkd-page/index.html');
const $ = cheerio.load(html); const $ = cheerio.load(html);
expect($('h1').html()).to.equal('Page with alternative .mkd extension'); assert.strictEqual($('h1').html(), 'Page with alternative .mkd extension');
expect($('p').html()).to.equal('Hope this loads fine 🤞'); assert.strictEqual($('p').html(), 'Hope this loads fine 🤞');
}); });
it('Can load a simple markdown page with Astro', async () => { it('Can load a simple markdown page with Astro', async () => {
const html = await fixture.readFile('/post/index.html'); const html = await fixture.readFile('/post/index.html');
const $ = cheerio.load(html); const $ = cheerio.load(html);
expect($('p').first().text()).to.equal('Hello world!'); assert.strictEqual($('p').first().text(), 'Hello world!');
expect($('#first').text()).to.equal('Some content'); assert.strictEqual($('#first').text(), 'Some content');
expect($('#interesting-topic').text()).to.equal('Interesting Topic'); assert.strictEqual($('#interesting-topic').text(), 'Interesting Topic');
}); });
it('Can load a realworld markdown page with Astro', async () => { it('Can load a realworld markdown page with Astro', async () => {
const html = await fixture.readFile('/realworld/index.html'); const html = await fixture.readFile('/realworld/index.html');
const $ = cheerio.load(html); const $ = cheerio.load(html);
expect($('pre')).to.have.lengthOf(7); assert.strictEqual($('pre').length, 7);
}); });
it('Does not unescape entities', async () => { it('Does not unescape entities', async () => {
const html = await fixture.readFile('/entities/index.html'); const html = await fixture.readFile('/entities/index.html');
expect(html).to.match(/<i>This should NOT be italic<\/i>/); assert.match(html, /<i>This should NOT be italic<\/i>/);
}); });
}); });
}); });