Home / File/ mdx-script-style-raw.test.js — astro Source File

mdx-script-style-raw.test.js — astro Source File

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

Entity Profile

Dependency Diagram

graph LR
  b899e421_f968_fa3e_db0f_eacea12d8dc5["mdx-script-style-raw.test.js"]
  0a624eac_945e_c9e8_c9de_3feb9de2dd15["test-utils.js"]
  b899e421_f968_fa3e_db0f_eacea12d8dc5 --> 0a624eac_945e_c9e8_c9de_3feb9de2dd15
  dd4f09ce_3fd7_8295_f616_8876cda4555c["loadFixture"]
  b899e421_f968_fa3e_db0f_eacea12d8dc5 --> dd4f09ce_3fd7_8295_f616_8876cda4555c
  e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"]
  b899e421_f968_fa3e_db0f_eacea12d8dc5 --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607
  6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"]
  b899e421_f968_fa3e_db0f_eacea12d8dc5 --> 6b0635f9_51ea_77aa_767b_7857878e98a6
  b05fd4c1_a3ee_3301_adcd_43b49bae78f1["mdx"]
  b899e421_f968_fa3e_db0f_eacea12d8dc5 --> b05fd4c1_a3ee_3301_adcd_43b49bae78f1
  cb315bcc_59d8_fa19_79aa_5da7cd3730c5["linkedom"]
  b899e421_f968_fa3e_db0f_eacea12d8dc5 --> cb315bcc_59d8_fa19_79aa_5da7cd3730c5
  style b899e421_f968_fa3e_db0f_eacea12d8dc5 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 mdx from '@astrojs/mdx';
import { parseHTML } from 'linkedom';
import { loadFixture } from '../../../astro/test/test-utils.js';

const FIXTURE_ROOT = new URL('./fixtures/mdx-script-style-raw/', import.meta.url);

describe('MDX script style raw', () => {
	describe('dev', () => {
		let fixture;
		let devServer;

		before(async () => {
			fixture = await loadFixture({
				root: FIXTURE_ROOT,
				integrations: [mdx()],
			});
			devServer = await fixture.startDevServer();
		});

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

		it('works with with raw script and style strings', async () => {
			const res = await fixture.fetch('/index.html');
			assert.equal(res.status, 200);

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

			const scriptContent = document.getElementById('test-script').innerHTML;
			assert.equal(
				scriptContent.includes("console.log('raw script')"),
				true,
				'script should not be html-escaped',
			);

			const styleContent = document.getElementById('test-style').innerHTML;
			assert.equal(
				styleContent.includes('h1[id="script-style-raw"]'),
				true,
				'style should not be html-escaped',
			);
		});
	});

	describe('build', () => {
		it('works with with raw script and style strings', async () => {
			const fixture = await loadFixture({
				root: FIXTURE_ROOT,
				integrations: [mdx()],
			});
			await fixture.build();

			const html = await fixture.readFile('/index.html');
			const { document } = parseHTML(html);

			const scriptContent = document.getElementById('test-script').innerHTML;
			assert.equal(
				scriptContent.includes("console.log('raw script')"),
				true,
				'script should not be html-escaped',
			);

			const styleContent = document.getElementById('test-style').innerHTML;
			assert.equal(
				styleContent.includes('h1[id="script-style-raw"]'),
				true,
				'style should not be html-escaped',
			);
		});
	});
});

Domain

Dependencies

Frequently Asked Questions

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