Home / File/ parseAstro.test.ts — astro Source File

parseAstro.test.ts — astro Source File

Architecture documentation for parseAstro.test.ts, a typescript file in the astro codebase. 6 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  44361e29_2da0_de2c_a680_9777761cdb6c["parseAstro.test.ts"]
  168af818_ad57_47d9_6b7e_1ff62cc0094f["../../dist/core/parseAstro.js"]
  44361e29_2da0_de2c_a680_9777761cdb6c --> 168af818_ad57_47d9_6b7e_1ff62cc0094f
  d8206fa8_f041_14e6_d043_1fc32953407c["utils.ts"]
  44361e29_2da0_de2c_a680_9777761cdb6c --> d8206fa8_f041_14e6_d043_1fc32953407c
  a81b6a03_7a0c_85e7_e1c2_2fec573d1cc4["createCompilerPoint"]
  44361e29_2da0_de2c_a680_9777761cdb6c --> a81b6a03_7a0c_85e7_e1c2_2fec573d1cc4
  b226d1f4_47aa_9abe_010b_0decbbdd837d["createCompilerPosition"]
  44361e29_2da0_de2c_a680_9777761cdb6c --> b226d1f4_47aa_9abe_010b_0decbbdd837d
  db323e8c_04ef_9777_0487_224de5819a30["node:assert"]
  44361e29_2da0_de2c_a680_9777761cdb6c --> db323e8c_04ef_9777_0487_224de5819a30
  6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"]
  44361e29_2da0_de2c_a680_9777761cdb6c --> 6b0635f9_51ea_77aa_767b_7857878e98a6
  style 44361e29_2da0_de2c_a680_9777761cdb6c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import assert from 'node:assert';
import { describe, it } from 'node:test';
import { getAstroMetadata } from '../../dist/core/parseAstro.js';
import { createCompilerPoint, createCompilerPosition } from '../utils.ts';

describe('parseAstro - Can parse astro files', () => {
	it('Can parse files', () => {
		const input = `---\n--- <div>Astro!</div>`;
		const metadata = getAstroMetadata('file.astro', input);

		assert.deepStrictEqual(metadata.ast, {
			children: [
				{
					position: createCompilerPosition(
						createCompilerPoint(1, 1, 0),
						createCompilerPoint(2, 4, 7),
					),
					type: 'frontmatter',
					value: '\n',
				},
				{
					attributes: [],
					children: [
						{
							position: createCompilerPosition(
								createCompilerPoint(2, 10, 13),
								createCompilerPoint(2, 16, 19),
							),
							type: 'text',
							value: 'Astro!',
						},
					],
					name: 'div',
					position: createCompilerPosition(
						createCompilerPoint(2, 5, 8),
						createCompilerPoint(2, 22, 25),
					),
					type: 'element',
				},
			],
			type: 'root',
		});
		assert.deepStrictEqual(metadata.frontmatter, {
			status: 'closed',
			position: {
				start: {
					line: 1,
					offset: 0,
					column: 1,
				},
				end: {
					line: 2,
					column: 4,
					offset: 7,
				},
			},
		});
		assert.deepStrictEqual(metadata.diagnostics, []);
	});

	it('properly return frontmatter states', () => {
		const inputClosed = `---\n--- <div>Astro!</div>`;
		assert.strictEqual(getAstroMetadata('file.astro', inputClosed).frontmatter.status, 'closed');

		const inputOpen = `---\n<div>Astro!</div>`;
		assert.strictEqual(getAstroMetadata('file.astro', inputOpen).frontmatter.status, 'open');

		const inputNull = `<div>Astro!</div>`;
		assert.strictEqual(
			getAstroMetadata('file.astro', inputNull).frontmatter.status,
			'doesnt-exist',
		);
	});
});

Domain

Dependencies

Frequently Asked Questions

What does parseAstro.test.ts do?
parseAstro.test.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain.
What does parseAstro.test.ts depend on?
parseAstro.test.ts imports 6 module(s): ../../dist/core/parseAstro.js, createCompilerPoint, createCompilerPosition, node:assert, node:test, utils.ts.
Where is parseAstro.test.ts in the architecture?
parseAstro.test.ts is located at packages/language-tools/language-server/test/units/parseAstro.test.ts (domain: CoreAstro, directory: packages/language-tools/language-server/test/units).

Analyze Your Own Codebase

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

Try Supermodel Free