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

astro-markdown-plugins.test.js — astro Source File

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

Entity Profile

Dependency Diagram

graph LR
  a3b948f7_bd67_8907_2296_e4b82b503528["astro-markdown-plugins.test.js"]
  21da64a9_eeec_ef2d_5a73_02ce749c1e00["add-classes.mjs"]
  a3b948f7_bd67_8907_2296_e4b82b503528 --> 21da64a9_eeec_ef2d_5a73_02ce749c1e00
  0a624eac_945e_c9e8_c9de_3feb9de2dd15["test-utils.js"]
  a3b948f7_bd67_8907_2296_e4b82b503528 --> 0a624eac_945e_c9e8_c9de_3feb9de2dd15
  dd4f09ce_3fd7_8295_f616_8876cda4555c["loadFixture"]
  a3b948f7_bd67_8907_2296_e4b82b503528 --> dd4f09ce_3fd7_8295_f616_8876cda4555c
  e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"]
  a3b948f7_bd67_8907_2296_e4b82b503528 --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607
  6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"]
  a3b948f7_bd67_8907_2296_e4b82b503528 --> 6b0635f9_51ea_77aa_767b_7857878e98a6
  deb87372_5629_35f8_9a54_e755a08f776a["cheerio"]
  a3b948f7_bd67_8907_2296_e4b82b503528 --> deb87372_5629_35f8_9a54_e755a08f776a
  style a3b948f7_bd67_8907_2296_e4b82b503528 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 addClasses from './fixtures/astro-markdown-plugins/add-classes.mjs';
import { loadFixture } from './test-utils.js';

const defaultMarkdownConfig = {
	gfm: true,
	smartypants: true,
	remarkPlugins: [
		remarkExamplePlugin,
		'remark-code-titles',
		['rehype-autolink-headings', { behavior: 'prepend' }],
	],
	rehypePlugins: [
		'rehype-slug',
		['rehype-toc', { headings: ['h2', 'h3'] }],
		[addClasses, { 'h1,h2,h3': 'title' }],
	],
};

function remarkExamplePlugin() {
	return (tree) => {
		tree.children.push({
			type: 'paragraph',
			children: [{ type: 'text', value: 'Remark plugin applied!' }],
		});
	};
}

describe('Astro Markdown plugins', () => {
	describe('Default test plugins', () => {
		let fixture;

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

		it('Can render markdown with plugins', async () => {
			const html = await fixture.readFile('/index.html');
			const $ = cheerio.load(html);

			// test 1: Added a TOC
			assert.equal($('.toc').length, 1);

			// test 2: Added .title to h1
			assert.ok($('#hello-world').hasClass('title'));
		});

		// Asserts Astro 1.0 behavior is removed. Test can be removed in Astro 3.0.
		it('Still applies default plugins when user plugins are provided', async () => {
			const gfmHtml = await fixture.readFile('/with-gfm/index.html');
			const $1 = cheerio.load(gfmHtml);
			assert.equal($1('a[href="https://example.com"]').length, 1);

// ... (100 more lines)

Subdomains

Dependencies

Frequently Asked Questions

What does astro-markdown-plugins.test.js do?
astro-markdown-plugins.test.js is a source file in the astro codebase, written in javascript. It belongs to the IntegrationAdapters domain, SsrAdapters subdomain.
What functions are defined in astro-markdown-plugins.test.js?
astro-markdown-plugins.test.js defines 3 function(s): remarkExamplePlugin, testRehype, testRemark.
What does astro-markdown-plugins.test.js depend on?
astro-markdown-plugins.test.js imports 6 module(s): add-classes.mjs, cheerio, loadFixture, node:test, strict, test-utils.js.
Where is astro-markdown-plugins.test.js in the architecture?
astro-markdown-plugins.test.js is located at packages/astro/test/astro-markdown-plugins.test.js (domain: IntegrationAdapters, subdomain: SsrAdapters, directory: packages/astro/test).

Analyze Your Own Codebase

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

Try Supermodel Free