mirror of
https://github.com/withastro/astro.git
synced 2025-01-06 22:10:10 -05:00
chore: Migrate astro-markdown-frontmatter-injection.test.js
to node:test
(#10019)
* Add astro-markdown-frontmatter-injection.nodetest.js * remove comment * remove old test
This commit is contained in:
parent
14ce8a6ebf
commit
191fd39708
1 changed files with 9 additions and 8 deletions
|
@ -1,4 +1,5 @@
|
|||
import { expect } from 'chai';
|
||||
import assert from 'node:assert/strict';
|
||||
import { describe, before, it } from 'node:test';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
|
||||
const FIXTURE_ROOT = './fixtures/astro-markdown-frontmatter-injection/';
|
||||
|
@ -16,8 +17,8 @@ describe('Astro Markdown - frontmatter injection', () => {
|
|||
it('remark supports custom vfile data - get title', async () => {
|
||||
const frontmatterByPage = JSON.parse(await fixture.readFile('/glob.json'));
|
||||
const titles = frontmatterByPage.map((frontmatter = {}) => frontmatter.title);
|
||||
expect(titles).to.contain('Page 1');
|
||||
expect(titles).to.contain('Page 2');
|
||||
assert.ok(titles.includes('Page 1'));
|
||||
assert.ok(titles.includes('Page 2'));
|
||||
});
|
||||
|
||||
it('rehype supports custom vfile data - reading time', async () => {
|
||||
|
@ -25,17 +26,17 @@ describe('Astro Markdown - frontmatter injection', () => {
|
|||
const readingTimes = frontmatterByPage.map(
|
||||
(frontmatter = {}) => frontmatter.injectedReadingTime
|
||||
);
|
||||
expect(readingTimes.length).to.be.greaterThan(0);
|
||||
assert.ok(readingTimes.length > 0);
|
||||
for (let readingTime of readingTimes) {
|
||||
expect(readingTime).to.not.be.null;
|
||||
expect(readingTime.text).match(/^\d+ min read/);
|
||||
assert.notStrictEqual(readingTime, null);
|
||||
assert.match(readingTime.text, /^\d+ min read/);
|
||||
}
|
||||
});
|
||||
|
||||
it('allow user frontmatter mutation', async () => {
|
||||
const frontmatterByPage = JSON.parse(await fixture.readFile('/glob.json'));
|
||||
const descriptions = frontmatterByPage.map((frontmatter = {}) => frontmatter.description);
|
||||
expect(descriptions).to.contain('Processed by remarkDescription plugin: Page 1 description');
|
||||
expect(descriptions).to.contain('Processed by remarkDescription plugin: Page 2 description');
|
||||
assert.ok(descriptions.includes('Processed by remarkDescription plugin: Page 1 description'));
|
||||
assert.ok(descriptions.includes('Processed by remarkDescription plugin: Page 2 description'));
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue