mdx-frontmatter-injection.test.js — astro Source File
Architecture documentation for mdx-frontmatter-injection.test.js, a javascript file in the astro codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 28f5b267_874e_2a49_3891_6bb4647bc25d["mdx-frontmatter-injection.test.js"] 0a624eac_945e_c9e8_c9de_3feb9de2dd15["test-utils.js"] 28f5b267_874e_2a49_3891_6bb4647bc25d --> 0a624eac_945e_c9e8_c9de_3feb9de2dd15 dd4f09ce_3fd7_8295_f616_8876cda4555c["loadFixture"] 28f5b267_874e_2a49_3891_6bb4647bc25d --> dd4f09ce_3fd7_8295_f616_8876cda4555c e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"] 28f5b267_874e_2a49_3891_6bb4647bc25d --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607 6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"] 28f5b267_874e_2a49_3891_6bb4647bc25d --> 6b0635f9_51ea_77aa_767b_7857878e98a6 cb315bcc_59d8_fa19_79aa_5da7cd3730c5["linkedom"] 28f5b267_874e_2a49_3891_6bb4647bc25d --> cb315bcc_59d8_fa19_79aa_5da7cd3730c5 style 28f5b267_874e_2a49_3891_6bb4647bc25d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import * as assert from 'node:assert/strict';
import { before, describe, it } from 'node:test';
import { parseHTML } from 'linkedom';
import { loadFixture } from '../../../astro/test/test-utils.js';
const FIXTURE_ROOT = new URL('./fixtures/mdx-frontmatter-injection/', import.meta.url);
describe('MDX frontmatter injection', () => {
let fixture;
before(async () => {
fixture = await loadFixture({
root: FIXTURE_ROOT,
});
await fixture.build();
});
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);
assert.equal(titles.includes('Page 1'), true);
assert.equal(titles.includes('Page 2'), true);
});
it('rehype supports custom vfile data - reading time', async () => {
const frontmatterByPage = JSON.parse(await fixture.readFile('/glob.json'));
const readingTimes = frontmatterByPage.map(
(frontmatter = {}) => frontmatter.injectedReadingTime,
);
assert.equal(readingTimes.length > 0, true);
for (let readingTime of readingTimes) {
assert.notEqual(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);
assert.equal(
descriptions.includes('Processed by remarkDescription plugin: Page 1 description'),
true,
);
assert.equal(
descriptions.includes('Processed by remarkDescription plugin: Page 2 description'),
true,
);
});
it('passes injected frontmatter to layouts', async () => {
const html1 = await fixture.readFile('/page-1/index.html');
const html2 = await fixture.readFile('/page-2/index.html');
const title1 = parseHTML(html1).document.querySelector('title');
const title2 = parseHTML(html2).document.querySelector('title');
assert.equal(title1.innerHTML, 'Page 1');
assert.equal(title2.innerHTML, 'Page 2');
});
});
Domain
Dependencies
- linkedom
- loadFixture
- node:test
- strict
- test-utils.js
Source
Frequently Asked Questions
What does mdx-frontmatter-injection.test.js do?
mdx-frontmatter-injection.test.js is a source file in the astro codebase, written in javascript. It belongs to the CoreAstro domain.
What does mdx-frontmatter-injection.test.js depend on?
mdx-frontmatter-injection.test.js imports 5 module(s): linkedom, loadFixture, node:test, strict, test-utils.js.
Where is mdx-frontmatter-injection.test.js in the architecture?
mdx-frontmatter-injection.test.js is located at packages/integrations/mdx/test/mdx-frontmatter-injection.test.js (domain: CoreAstro, directory: packages/integrations/mdx/test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free