Home / File/ mdx-page.test.js — astro Source File

mdx-page.test.js — astro Source File

Architecture documentation for mdx-page.test.js, a javascript file in the astro codebase. 6 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  d994d7aa_f18a_7070_0760_2a9884ca029a["mdx-page.test.js"]
  0a624eac_945e_c9e8_c9de_3feb9de2dd15["test-utils.js"]
  d994d7aa_f18a_7070_0760_2a9884ca029a --> 0a624eac_945e_c9e8_c9de_3feb9de2dd15
  dd4f09ce_3fd7_8295_f616_8876cda4555c["loadFixture"]
  d994d7aa_f18a_7070_0760_2a9884ca029a --> dd4f09ce_3fd7_8295_f616_8876cda4555c
  e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"]
  d994d7aa_f18a_7070_0760_2a9884ca029a --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607
  6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"]
  d994d7aa_f18a_7070_0760_2a9884ca029a --> 6b0635f9_51ea_77aa_767b_7857878e98a6
  deb87372_5629_35f8_9a54_e755a08f776a["cheerio"]
  d994d7aa_f18a_7070_0760_2a9884ca029a --> deb87372_5629_35f8_9a54_e755a08f776a
  cb315bcc_59d8_fa19_79aa_5da7cd3730c5["linkedom"]
  d994d7aa_f18a_7070_0760_2a9884ca029a --> cb315bcc_59d8_fa19_79aa_5da7cd3730c5
  style d994d7aa_f18a_7070_0760_2a9884ca029a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import * as assert from 'node:assert/strict';
import { after, before, describe, it } from 'node:test';
import * as cheerio from 'cheerio';
import { parseHTML } from 'linkedom';
import { loadFixture } from '../../../astro/test/test-utils.js';

describe('MDX Page', () => {
	let fixture;

	before(async () => {
		fixture = await loadFixture({
			root: new URL('./fixtures/mdx-page/', import.meta.url),
			// test suite was authored when inlineStylesheets defaulted to never
			build: { inlineStylesheets: 'never' },
		});
	});

	describe('build', () => {
		before(async () => {
			await fixture.build();
		});

		it('works', async () => {
			const html = await fixture.readFile('/index.html');
			const { document } = parseHTML(html);

			const h1 = document.querySelector('h1');

			assert.equal(h1.textContent, 'Hello page!');
		});

		it('injects style imports when layout is not applied', async () => {
			const html = await fixture.readFile('/index.html');
			const { document } = parseHTML(html);

			const stylesheet = document.querySelector('link[rel="stylesheet"]');

			assert.notEqual(stylesheet, null);
		});

		it('Renders MDX in utf-8 by default', async () => {
			const html = await fixture.readFile('/chinese-encoding/index.html');
			const $ = cheerio.load(html);
			assert.equal($('h1').text(), '我的第一篇博客文章');
			assert.match(html, /<meta charset="utf-8"/);
		});

		it('Renders MDX with layout frontmatter without utf-8 by default', async () => {
			const html = await fixture.readFile('/chinese-encoding-layout-frontmatter/index.html');
			assert.doesNotMatch(html, /<meta charset="utf-8"/);
		});

		it('Renders MDX with layout manual import without utf-8 by default', async () => {
			const html = await fixture.readFile('/chinese-encoding-layout-manual/index.html');
			assert.doesNotMatch(html, /<meta charset="utf-8"/);
		});

		it('renders MDX with key prop', async () => {
			const html = await fixture.readFile('/index.html');
			const { document } = parseHTML(html);

			const keyTest = document.querySelector('#key-test');
			assert.equal(keyTest.textContent, 'oranges');
		});
	});

	describe('dev', () => {
		let devServer;

		before(async () => {
			devServer = await fixture.startDevServer();
		});

		after(async () => {
			await devServer.stop();
		});

		it('works', async () => {
			const res = await fixture.fetch('/');

			assert.equal(res.status, 200);

			const html = await res.text();
			const { document } = parseHTML(html);

			const h1 = document.querySelector('h1');

			assert.equal(h1.textContent, 'Hello page!');
		});

		it('Renders MDX in utf-8 by default', async () => {
			const res = await fixture.fetch('/chinese-encoding/');
			assert.equal(res.status, 200);
			const html = await res.text();
			const $ = cheerio.load(html);
			assert.equal($('h1').text(), '我的第一篇博客文章');
			assert.doesNotMatch(res.headers.get('content-type'), /charset=utf-8/);
			assert.match(html, /<meta charset="utf-8"/);
		});

		it('Renders MDX with layout frontmatter without utf-8 by default', async () => {
			const res = await fixture.fetch('/chinese-encoding-layout-frontmatter/');
			assert.equal(res.status, 200);
			const html = await res.text();
			assert.doesNotMatch(res.headers.get('content-type'), /charset=utf-8/);
			assert.doesNotMatch(html, /<meta charset="utf-8"/);
		});

		it('Renders MDX with layout manual import without utf-8 by default', async () => {
			const res = await fixture.fetch('/chinese-encoding-layout-manual/');
			assert.equal(res.status, 200);
			const html = await res.text();
			assert.doesNotMatch(res.headers.get('content-type'), /charset=utf-8/);
			assert.doesNotMatch(html, /<meta charset="utf-8"/);
		});
	});
});

Domain

Dependencies

Frequently Asked Questions

What does mdx-page.test.js do?
mdx-page.test.js is a source file in the astro codebase, written in javascript. It belongs to the CoreAstro domain.
What does mdx-page.test.js depend on?
mdx-page.test.js imports 6 module(s): cheerio, linkedom, loadFixture, node:test, strict, test-utils.js.
Where is mdx-page.test.js in the architecture?
mdx-page.test.js is located at packages/integrations/mdx/test/mdx-page.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