Home / File/ propagated-assets.test.js — astro Source File

propagated-assets.test.js — astro Source File

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

Entity Profile

Dependency Diagram

graph LR
  d708564b_e462_2a2e_726e_a068d67d3436["propagated-assets.test.js"]
  0a624eac_945e_c9e8_c9de_3feb9de2dd15["test-utils.js"]
  d708564b_e462_2a2e_726e_a068d67d3436 --> 0a624eac_945e_c9e8_c9de_3feb9de2dd15
  dd4f09ce_3fd7_8295_f616_8876cda4555c["loadFixture"]
  d708564b_e462_2a2e_726e_a068d67d3436 --> dd4f09ce_3fd7_8295_f616_8876cda4555c
  e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"]
  d708564b_e462_2a2e_726e_a068d67d3436 --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607
  6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"]
  d708564b_e462_2a2e_726e_a068d67d3436 --> 6b0635f9_51ea_77aa_767b_7857878e98a6
  cb315bcc_59d8_fa19_79aa_5da7cd3730c5["linkedom"]
  d708564b_e462_2a2e_726e_a068d67d3436 --> cb315bcc_59d8_fa19_79aa_5da7cd3730c5
  style d708564b_e462_2a2e_726e_a068d67d3436 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 { parseHTML } from 'linkedom';
import { loadFixture } from '../../../astro/test/test-utils.js';

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

	const modes = ['dev', 'prod'];

	for (const mode of modes) {
		describe(mode, () => {
			/** @type {Document} */
			let stylesDocument;
			/** @type {Document} */
			let scriptsDocument;

			before(async () => {
				if (mode === 'prod') {
					await fixture.build();
					stylesDocument = parseHTML(await fixture.readFile('/styles/index.html')).document;
					scriptsDocument = parseHTML(await fixture.readFile('/scripts/index.html')).document;
				} else if (mode === 'dev') {
					devServer = await fixture.startDevServer();
					const styleRes = await fixture.fetch('/styles');
					const scriptRes = await fixture.fetch('/scripts');
					stylesDocument = parseHTML(await styleRes.text()).document;
					scriptsDocument = parseHTML(await scriptRes.text()).document;
				}
			});

			after(async () => {
				if (mode === 'dev') devServer?.stop();
			});

			it('Bundles styles', async () => {
				let styleContents;
				if (mode === 'dev') {
					const styles = stylesDocument.querySelectorAll('style');
					assert.equal(styles.length, 1);
					styleContents = styles[0].textContent;
				} else {
					const links = stylesDocument.querySelectorAll('link[rel="stylesheet"]');
					assert.equal(links.length, 1);
					styleContents = await fixture.readFile(links[0].href);
				}
				assert.equal(styleContents.includes('--color-base-purple: 269, 79%;'), true);
			});

			it('[fails] Does not bleed styles to other page', async () => {
				if (mode === 'dev') {
					const styles = scriptsDocument.querySelectorAll('style');
					assert.equal(styles.length, 0);
				} else {
					const links = scriptsDocument.querySelectorAll('link[rel="stylesheet"]');
					assert.equal(links.length, 0);
				}
			});
		});
	}
});

Domain

Dependencies

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free