Home / File/ content-layer-markdoc.test.js — astro Source File

content-layer-markdoc.test.js — astro Source File

Architecture documentation for content-layer-markdoc.test.js, a javascript file in the astro codebase. 5 imports, 0 dependents.

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

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

describe('Content layer markdoc', () => {
	let fixture;

	before(async () => {
		fixture = await loadFixture({
			root: './fixtures/content-layer-markdoc/',
		});
	});

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

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

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

		it('renders content - with components', async () => {
			const res = await fixture.fetch('/');
			const html = await res.text();

			renderComponentsChecks(html);
		});

		it('renders content - with components inside partials', async () => {
			const res = await fixture.fetch('/');
			const html = await res.text();

			renderComponentsInsidePartialsChecks(html);
		});
	});

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

		it('renders content - with components', async () => {
			const html = await fixture.readFile('/index.html');

			renderComponentsChecks(html);
		});

		it('renders content - with components inside partials', async () => {
			const html = await fixture.readFile('/index.html');

			renderComponentsInsidePartialsChecks(html);
		});
	});
});

/** @param {string} html */
function renderComponentsChecks(html) {
	const $ = cheerio.load(html);
	const h2 = $('h2');
	assert.equal(h2.text(), 'Post with components');

	// Renders custom shortcode component
	const marquee = $('marquee');
	assert.notEqual(marquee, null);
	assert.equal(marquee.attr('data-custom-marquee'), '');

	// Renders Astro Code component
	const pre = $('pre');
	assert.notEqual(pre, null);
	assert.ok(pre.hasClass('github-dark'));
	assert.ok(pre.hasClass('astro-code'));
}

/** @param {string} html */
function renderComponentsInsidePartialsChecks(html) {
	const $ = cheerio.load(html);
	// renders Counter.tsx
	const button = $('#counter');
	assert.equal(button.text(), '1');

	// renders DeeplyNested.astro
	const deeplyNested = $('#deeply-nested');
	assert.equal(deeplyNested.text(), 'Deeply nested partial');
}

Subdomains

Dependencies

Frequently Asked Questions

What does content-layer-markdoc.test.js do?
content-layer-markdoc.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 content-layer-markdoc.test.js?
content-layer-markdoc.test.js defines 2 function(s): renderComponentsChecks, renderComponentsInsidePartialsChecks.
What does content-layer-markdoc.test.js depend on?
content-layer-markdoc.test.js imports 5 module(s): cheerio, loadFixture, node:test, strict, test-utils.js.
Where is content-layer-markdoc.test.js in the architecture?
content-layer-markdoc.test.js is located at packages/astro/test/content-layer-markdoc.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