utils.test.ts — astro Source File
Architecture documentation for utils.test.ts, a typescript file in the astro codebase. 9 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 034fb8d9_2351_4bcf_b163_3beca526460f["utils.test.ts"] e660f855_08b1_35ca_393f_c779256618fe["../../dist/core/astro2tsx.js"] 034fb8d9_2351_4bcf_b163_3beca526460f --> e660f855_08b1_35ca_393f_c779256618fe e5da799b_caa1_df6d_957b_858c818c012e["../../dist/core/compilerUtils.js"] 034fb8d9_2351_4bcf_b163_3beca526460f --> e5da799b_caa1_df6d_957b_858c818c012e 168af818_ad57_47d9_6b7e_1ff62cc0094f["../../dist/core/parseAstro.js"] 034fb8d9_2351_4bcf_b163_3beca526460f --> 168af818_ad57_47d9_6b7e_1ff62cc0094f d72b8b61_3d86_8198_cbe3_721d672d8a46["../../dist/plugins/utils.js"] 034fb8d9_2351_4bcf_b163_3beca526460f --> d72b8b61_3d86_8198_cbe3_721d672d8a46 db323e8c_04ef_9777_0487_224de5819a30["node:assert"] 034fb8d9_2351_4bcf_b163_3beca526460f --> db323e8c_04ef_9777_0487_224de5819a30 6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"] 034fb8d9_2351_4bcf_b163_3beca526460f --> 6b0635f9_51ea_77aa_767b_7857878e98a6 6ac31939_c054_c427_eb8e_cd2cf57d9cf6["types.js"] 034fb8d9_2351_4bcf_b163_3beca526460f --> 6ac31939_c054_c427_eb8e_cd2cf57d9cf6 6857b6b2_4d48_bfb0_0a0e_8e2e52fabb56["language-server"] 034fb8d9_2351_4bcf_b163_3beca526460f --> 6857b6b2_4d48_bfb0_0a0e_8e2e52fabb56 4e2ee814_ff7b_a348_0e3a_6e6d7b34afb6["vscode-html-languageservice"] 034fb8d9_2351_4bcf_b163_3beca526460f --> 4e2ee814_ff7b_a348_0e3a_6e6d7b34afb6 style 034fb8d9_2351_4bcf_b163_3beca526460f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import assert from 'node:assert';
import { describe, it } from 'node:test';
import type { Point } from '@astrojs/compiler/types.js';
import { Range } from '@volar/language-server';
import type { Node } from 'vscode-html-languageservice';
import * as html from 'vscode-html-languageservice';
import { getTSXRangesAsLSPRanges, safeConvertToTSX } from '../../dist/core/astro2tsx.js';
import * as compilerUtils from '../../dist/core/compilerUtils.js';
import { getAstroMetadata } from '../../dist/core/parseAstro.js';
import * as utils from '../../dist/plugins/utils.js';
describe('Utilities', async () => {
it('isTsDocument - properly return if a document is JavaScript', () => {
assert.strictEqual(utils.isJSDocument('javascript'), true);
assert.strictEqual(utils.isJSDocument('typescript'), true);
assert.strictEqual(utils.isJSDocument('javascriptreact'), true);
assert.strictEqual(utils.isJSDocument('typescriptreact'), true);
});
it('isPossibleComponent - properly return if a node is a component', () => {
const node = {
tag: 'div',
} as Node;
assert.strictEqual(utils.isPossibleComponent(node), false);
const component = {
tag: 'MyComponent',
} as Node;
assert.strictEqual(utils.isPossibleComponent(component), true);
const namespacedComponent = {
tag: 'components.MyOtherComponent',
} as Node;
assert.strictEqual(utils.isPossibleComponent(namespacedComponent), true);
});
it('isInComponentStartTag - properly return if a given offset is inside the start tag of a component', () => {
const htmlLs = html.getLanguageService();
const htmlContent = `<div><Component astr></Component></div>`;
const htmlDoc = htmlLs.parseHTMLDocument({ getText: () => htmlContent } as any);
assert.strictEqual(utils.isInComponentStartTag(htmlDoc, 3), false);
assert.strictEqual(utils.isInComponentStartTag(htmlDoc, 16), true);
});
it('isInsideExpression - properly return if a given position is inside a JSX expression', () => {
const template = `<div>{expression}</div>`;
assert.strictEqual(utils.isInsideExpression(template, 0, 0), false);
assert.strictEqual(utils.isInsideExpression(template, 0, 6), true);
});
it('isInsideFrontmatter - properly return if a given offset is inside the frontmatter', () => {
const hasFrontmatter = getAstroMetadata('file.astro', '---\nfoo\n---\n');
assert.strictEqual(utils.isInsideFrontmatter(0, hasFrontmatter.frontmatter), false);
assert.strictEqual(utils.isInsideFrontmatter(6, hasFrontmatter.frontmatter), true);
assert.strictEqual(utils.isInsideFrontmatter(15, hasFrontmatter.frontmatter), false);
const noFrontmatter = getAstroMetadata('file.astro', '<div></div>');
assert.strictEqual(utils.isInsideFrontmatter(0, noFrontmatter.frontmatter), false);
assert.strictEqual(utils.isInsideFrontmatter(6, noFrontmatter.frontmatter), false);
// ... (77 more lines)
Domain
Dependencies
- ../../dist/core/astro2tsx.js
- ../../dist/core/compilerUtils.js
- ../../dist/core/parseAstro.js
- ../../dist/plugins/utils.js
- language-server
- node:assert
- node:test
- types.js
- vscode-html-languageservice
Source
Frequently Asked Questions
What does utils.test.ts do?
utils.test.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain.
What does utils.test.ts depend on?
utils.test.ts imports 9 module(s): ../../dist/core/astro2tsx.js, ../../dist/core/compilerUtils.js, ../../dist/core/parseAstro.js, ../../dist/plugins/utils.js, language-server, node:assert, node:test, types.js, and 1 more.
Where is utils.test.ts in the architecture?
utils.test.ts is located at packages/language-tools/language-server/test/units/utils.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