Home / File/ head-injection.test.js — astro Source File

head-injection.test.js — astro Source File

Architecture documentation for head-injection.test.js, a javascript file in the astro codebase. 7 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  3d1e6b18_076a_6a07_9ffb_17c7a0fefbc8["head-injection.test.js"]
  b0be4d0c_86b6_a283_f2af_003189bfd572["test-utils.js"]
  3d1e6b18_076a_6a07_9ffb_17c7a0fefbc8 --> b0be4d0c_86b6_a283_f2af_003189bfd572
  f0937d94_cf30_e0fa_fbd5_135f8c876f70["createFixture"]
  3d1e6b18_076a_6a07_9ffb_17c7a0fefbc8 --> f0937d94_cf30_e0fa_fbd5_135f8c876f70
  37bee138_718e_22c5_b294_37b0235244a2["createRequestAndResponse"]
  3d1e6b18_076a_6a07_9ffb_17c7a0fefbc8 --> 37bee138_718e_22c5_b294_37b0235244a2
  f09af995_6d60_a9f3_bdf0_6ae561f198cb["runInContainer"]
  3d1e6b18_076a_6a07_9ffb_17c7a0fefbc8 --> f09af995_6d60_a9f3_bdf0_6ae561f198cb
  e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"]
  3d1e6b18_076a_6a07_9ffb_17c7a0fefbc8 --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607
  6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"]
  3d1e6b18_076a_6a07_9ffb_17c7a0fefbc8 --> 6b0635f9_51ea_77aa_767b_7857878e98a6
  deb87372_5629_35f8_9a54_e755a08f776a["cheerio"]
  3d1e6b18_076a_6a07_9ffb_17c7a0fefbc8 --> deb87372_5629_35f8_9a54_e755a08f776a
  style 3d1e6b18_076a_6a07_9ffb_17c7a0fefbc8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

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

const root = new URL('../../fixtures/alias/', import.meta.url);

describe('head injection', () => {
	it('Dynamic injection from component created in the page frontmatter', async () => {
		const fixture = await createFixture(
			{
				'/src/components/Other.astro': `
					<style>
						div {
							background: grey;
						}
					</style>
					<div id="other">Other</div>
				`,
				'/src/common/head.js': `
					// astro-head-inject
					import Other from '../components/Other.astro';
					import {
						createComponent,
						createHeadAndContent,
						renderComponent,
						renderTemplate,
						renderUniqueStylesheet,
						unescapeHTML
					} from 'astro/runtime/server/index.js';

					export function renderEntry() {
						return createComponent({
							factory(result, props, slots) {
								return createHeadAndContent(
									unescapeHTML(renderUniqueStylesheet(result, {
										type: 'external',
										src: '/some/fake/styles.css'
									})),
									renderTemplate\`$\{renderComponent(result, 'Other', Other, props, slots)}\`
								);
							},
							propagation: 'self'
						});
					}
				`.trim(),
				'/src/pages/index.astro': `
					---
					import { renderEntry } from '../common/head.js';
					const Head = renderEntry();
					---
					<html>
						<head><title>Testing</title></head>
						<body>
							<h1>testing</h1>
							<Head />
						</body>
					</html>
				`,
			},
// ... (130 more lines)

Frequently Asked Questions

What does head-injection.test.js do?
head-injection.test.js is a source file in the astro codebase, written in javascript. It belongs to the IntegrationAdapters domain.
What does head-injection.test.js depend on?
head-injection.test.js imports 7 module(s): cheerio, createFixture, createRequestAndResponse, node:test, runInContainer, strict, test-utils.js.
Where is head-injection.test.js in the architecture?
head-injection.test.js is located at packages/astro/test/units/dev/head-injection.test.js (domain: IntegrationAdapters, directory: packages/astro/test/units/dev).

Analyze Your Own Codebase

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

Try Supermodel Free