Home / File/ components.test.js — astro Source File

components.test.js — astro Source File

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

Entity Profile

Dependency Diagram

graph LR
  55f60957_9521_a673_220f_7040eaa1b6b8["components.test.js"]
  b0be4d0c_86b6_a283_f2af_003189bfd572["test-utils.js"]
  55f60957_9521_a673_220f_7040eaa1b6b8 --> b0be4d0c_86b6_a283_f2af_003189bfd572
  f0937d94_cf30_e0fa_fbd5_135f8c876f70["createFixture"]
  55f60957_9521_a673_220f_7040eaa1b6b8 --> f0937d94_cf30_e0fa_fbd5_135f8c876f70
  37bee138_718e_22c5_b294_37b0235244a2["createRequestAndResponse"]
  55f60957_9521_a673_220f_7040eaa1b6b8 --> 37bee138_718e_22c5_b294_37b0235244a2
  f09af995_6d60_a9f3_bdf0_6ae561f198cb["runInContainer"]
  55f60957_9521_a673_220f_7040eaa1b6b8 --> f09af995_6d60_a9f3_bdf0_6ae561f198cb
  e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"]
  55f60957_9521_a673_220f_7040eaa1b6b8 --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607
  6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"]
  55f60957_9521_a673_220f_7040eaa1b6b8 --> 6b0635f9_51ea_77aa_767b_7857878e98a6
  deb87372_5629_35f8_9a54_e755a08f776a["cheerio"]
  55f60957_9521_a673_220f_7040eaa1b6b8 --> deb87372_5629_35f8_9a54_e755a08f776a
  style 55f60957_9521_a673_220f_7040eaa1b6b8 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';

describe('core/render components', () => {
	it('should sanitize dynamic tags', async () => {
		const fixture = await createFixture({
			'/src/pages/index.astro': `
				---
				const TagA = 'p style=color:red;'
				const TagB = 'p><script id="pwnd">console.log("pwnd")</script>'
				---
				<html>
					<head><title>testing</title></head>
					<body>
						<TagA id="target" />
						<TagB />
					</body>
				</html>
			`,
		});

		await runInContainer(
			{
				inlineConfig: {
					root: fixture.path,
					logLevel: 'silent',
					integrations: [],
				},
			},
			async (container) => {
				const { req, res, done, text } = createRequestAndResponse({
					method: 'GET',
					url: '/',
				});
				container.handle(req, res);

				await done;
				const html = await text();
				const $ = cheerio.load(html);
				const target = $('#target');

				assert.ok(target);
				assert.equal(target.attr('id'), 'target');
				assert.equal(typeof target.attr('style'), 'undefined');

				assert.equal($('#pwnd').length, 0);
			},
		);
	});

	it('should merge `class` and `class:list`', async () => {
		const fixture = await createFixture({
			'/src/pages/index.astro': `
				---
				import Class from '../components/Class.astro';
				import ClassList from '../components/ClassList.astro';
				import BothLiteral from '../components/BothLiteral.astro';
				import BothFlipped from '../components/BothFlipped.astro';
// ... (142 more lines)

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free