Skip to main content
Glama
push-based

Angular Toolkit MCP

by push-based
utils.unit.test.ts2.42 kB
import { describe, expect } from 'vitest'; import { tmplAstElementToSource } from './utils'; import type { TmplAstElement } from '@angular/compiler' with { 'resolution-mode': 'import' }; describe('tmplAstElementToSource', () => { let parseTemplate: typeof import('@angular/compiler').parseTemplate; beforeAll(async () => { parseTemplate = (await import('@angular/compiler')).parseTemplate; }); it('should have line number starting from 1', () => { const result = parseTemplate( `<button class="btn">click</button>`, 'inline-template.component.ts', ); const attribute = result.nodes.at(0) as TmplAstElement; const source = tmplAstElementToSource(attribute); expect(source).toStrictEqual({ file: 'inline-template.component.ts', position: { startLine: 1, }, }); }); it('should have line number where startLine is respected', () => { const result = parseTemplate( `<button class="btn">click</button>`, 'template.html', ); const attribute = (result.nodes.at(0) as TmplAstElement)?.attributes.at(0); const source = tmplAstElementToSource(attribute); expect(source).toStrictEqual({ file: expect.stringMatching(/template\.html$/), position: { startLine: 5, startColumn: 1, endLine: 5, endColumn: 19, }, }); }); it('should have correct line number for starting line breaks', () => { const result = parseTemplate( ` <button class="btn">click</button>`, 'template.html', ); const attribute = (result.nodes.at(0) as TmplAstElement)?.attributes.at(0); const source = tmplAstElementToSource(attribute); expect(source).toStrictEqual({ file: expect.stringMatching(/template\.html/), position: { startLine: 3, startColumn: 1, endLine: 3, endColumn: 19, }, }); }); it('should have correct line number for spans', () => { const result = parseTemplate( `<button class="btn"> click </button>`, 'template.html', ); const attribute = result.nodes.at(0)?.attributes.at(0); const source = tmplAstElementToSource(attribute); expect(source).toStrictEqual({ file: expect.stringMatching(/template\.html$/), position: { startLine: 1, startColumn: 1, endLine: 4, endColumn: 1, }, }); }); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/push-based/angular-toolkit-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server