Skip to content

Instantly share code, notes, and snippets.

@xMohamd
Created February 14, 2024 20:13
Show Gist options
  • Save xMohamd/8768fe20a882eb1cfd9b18bbc46df8aa to your computer and use it in GitHub Desktop.
Save xMohamd/8768fe20a882eb1cfd9b18bbc46df8aa to your computer and use it in GitHub Desktop.
defaultTest
@xMohamd ➜ /workspaces/astro-language-tools/packages/language-server (main) $ pnpm run test > defaultTest.txt
> @astrojs/language-server@2.7.2 test /workspaces/astro-language-tools/packages/language-server
> mocha --timeout 10000 --require tsx --require test/takedown.ts test/misc/init.test.ts test/**/*.test.ts
Initialize
✔ Can start server
✔ Has proper capabilities
AstroCheck
✔ Can check files and return errors
✔ Returns the file's URL
✔ Returns the file's content
✔ Can return the total amount of errors, warnings and hints
✔ Can return the total amount of files checked
✔ Can return the status of the check
CSS - Completions
✔ Can provide completions for CSS properties
✔ Can provide completions for CSS values
✔ Can provide completions inside inline styles
CSS - Hover
✔ Can get hover in style tags (183ms)
HTML - Completions
✔ Can provide completions for HTML tags
✔ Can provide completions for HTML attributes
HTML - Hover
✔ Can provide hover for HTML tags (130ms)
✔ Can provide hover for HTML attributes (84ms)
Formatting
✔ Can format document (230ms)
TypeScript Addons - Completions
✔ Can provide neat snippets (275ms)
TypeScript - Completions
✔ Can get completions in the frontmatter (267ms)
{
jsonrpc: '2.0',
method: 'textDocument/publishDiagnostics',
params: {
uri: 'file:///does-not-exists-a_grltwTCtpez4szNUIniR_zoZN94suIo2xVuY7QBBo-.astro',
diagnostics: [],
version: 0
}
}
{
jsonrpc: '2.0',
method: 'textDocument/publishDiagnostics',
params: {
uri: 'file:///does-not-exists-qvmuXQvZQsK5cFuYjgRpvhhcMzCse2ZDm53IHqFZRhI-.astro',
diagnostics: [],
version: 0
}
}
✔ Can get completions in the template (345ms)
{
jsonrpc: '2.0',
method: 'textDocument/publishDiagnostics',
params: {
uri: 'file:///does-not-exists-qvmuXQvZQsK5cFuYjgRpvhhcMzCse2ZDm53IHqFZRhI-.astro',
diagnostics: [ [Object] ],
version: 0
}
}
{
jsonrpc: '2.0',
method: 'textDocument/publishDiagnostics',
params: {
uri: 'file:///does-not-exists-VnjkION-secVyHchsVHHrEMH-hmiyEOegsR0_ZWfJMU-.astro',
diagnostics: [],
version: 0
}
}
{
jsonrpc: '2.0',
method: 'textDocument/publishDiagnostics',
params: {
uri: 'file:///does-not-exists-VnjkION-secVyHchsVHHrEMH-hmiyEOegsR0_ZWfJMU-.astro',
diagnostics: [ [Object] ],
version: 0
}
}
✔ sort completions starting with `astro:` higher than other imports (222ms)
✔ Can get completions in all kinds of script tags (286ms)
TypeScript - Diagnostics
✔ Can get diagnostics in the frontmatter (104ms)
✔ Can get diagnostics in the template (129ms)
{
jsonrpc: '2.0',
method: 'textDocument/publishDiagnostics',
params: {
uri: 'file:///workspaces/astro-language-tools/packages/language-server/test/fixture/enhancedDiagnostics.astro',
diagnostics: [],
version: 0
}
}
{
jsonrpc: '2.0',
method: 'textDocument/publishDiagnostics',
params: {
uri: 'file:///workspaces/astro-language-tools/packages/language-server/test/fixture/enhancedDiagnostics.astro',
diagnostics: [ [Object], [Object] ],
version: 0
}
}
✔ shows enhanced diagnostics (1426ms)
✔ can get diagnostics in script tags (122ms)
parseAstro - Can parse astro files
✔ Can parse files
✔ properly return frontmatter states
parseCSS - Can find all the styles in an Astro file
✔ Can find all the styles in an Astro file, including nested tags
parseJS - Can find all the scripts in an Astro file
✔ Can find all the scripts in an Astro file, including nested tags
✔ Ignore JSON scripts
✔ returns the proper capabilities for inline script tags
Utilities
✔ isTsDocument - properly return if a document is JavaScript
✔ isPossibleComponent - properly return if a node is a component
✔ isInComponentStartTag - properly return if a given offset is inside the start tag of a component
✔ isInsideExpression - properly return if a given position is inside a JSX expression
✔ isInsideFrontmatter - properly return if a given offset is inside the frontmatter
✔ PointToPosition - properly transform a Point from the Astro compiler to an LSP Position
✔ ensureRangeIsInFrontmatter - properly return a range inside the frontmatter
✔ getNewFrontmatterEdit - properly return a new frontmatter edit
✔ getOpenFrontmatterEdit - properly return an open frontmatter edit
41 passing (9s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment