Home / File/ markdown.test.js — astro Source File

markdown.test.js — astro Source File

Architecture documentation for markdown.test.js, a javascript file in the astro codebase. 5 imports, 0 dependents.

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

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

describe('Markdown tests', () => {
	/** @type {import('./test-utils').Fixture} */
	let fixture;

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

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

		it('Can load a markdown page with the `.markdown` extension', async () => {
			const html = await fixture.readFile('/dot-markdown-page/index.html');
			const $ = cheerio.load(html);
			assert.equal($('h1').html(), 'Page with alternative .markdown extension');
			assert.equal($('p').html(), 'Hope this loads fine 🤞');
		});

		it('Can load a markdown page with the `.mdwn` extension', async () => {
			const html = await fixture.readFile('/dot-mdwn-page/index.html');
			const $ = cheerio.load(html);
			assert.equal($('h1').html(), 'Page with alternative .mdwn extension');
			assert.equal($('p').html(), 'Hope this loads fine 🤞');
		});

		it('Can load a markdown page with the `.mkdn` extension', async () => {
			const html = await fixture.readFile('/dot-mkdn-page/index.html');
			const $ = cheerio.load(html);
			assert.equal($('h1').html(), 'Page with alternative .mkdn extension');
			assert.equal($('p').html(), 'Hope this loads fine 🤞');
		});

		it('Can load a markdown page with the `.mdown` extension', async () => {
			const html = await fixture.readFile('/dot-mdown-page/index.html');
			const $ = cheerio.load(html);
			assert.equal($('h1').html(), 'Page with alternative .mdown extension');
			assert.equal($('p').html(), 'Hope this loads fine 🤞');
		});

		it('Can load a markdown page with the `.mkd` extension', async () => {
			const html = await fixture.readFile('/dot-mkd-page/index.html');
			const $ = cheerio.load(html);
			assert.equal($('h1').html(), 'Page with alternative .mkd extension');
			assert.equal($('p').html(), 'Hope this loads fine 🤞');
		});

		it('Can load a simple markdown page with Astro', async () => {
			const html = await fixture.readFile('/post/index.html');
			const $ = cheerio.load(html);

			assert.equal($('p').first().text(), 'Hello world!');
			assert.equal($('#first').text(), 'Some content');
			assert.equal($('#interesting-topic').text(), 'Interesting Topic');
		});

		it('Can load a realworld markdown page with Astro', async () => {
			const html = await fixture.readFile('/realworld/index.html');
			const $ = cheerio.load(html);
			assert.equal($('pre').length, 7);
		});

		it('Does not unescape entities', async () => {
			const html = await fixture.readFile('/entities/index.html');
			assert.match(html, /<i>This should NOT be italic<\/i>/);
		});

		it('Resolves the image paths correctly', async () => {
			const html = await fixture.readFile('/images/index.html');
			const $ = cheerio.load(html);
			assert.equal($('img').first().attr('src').includes('.webp'), true);
			assert.equal($('img').first().next().attr('src').includes('.webp'), true);
		});
	});
});

Dependencies

Frequently Asked Questions

What does markdown.test.js do?
markdown.test.js is a source file in the astro codebase, written in javascript. It belongs to the IntegrationAdapters domain.
What does markdown.test.js depend on?
markdown.test.js imports 5 module(s): cheerio, loadFixture, node:test, strict, test-utils.js.
Where is markdown.test.js in the architecture?
markdown.test.js is located at packages/astro/test/markdown.test.js (domain: IntegrationAdapters, directory: packages/astro/test).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free