Skip to content

Commit

Permalink
test: add tests for Svelte and Vue inside astro check
Browse files Browse the repository at this point in the history
  • Loading branch information
Princesseuh committed Feb 12, 2024
1 parent 5a5a098 commit 16756fb
Show file tree
Hide file tree
Showing 7 changed files with 299 additions and 336 deletions.
7 changes: 4 additions & 3 deletions packages/language-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@
"vscode-uri": "^3.0.8"
},
"devDependencies": {
"@astrojs/svelte": "^4.0.3",
"@astrojs/vue": "^3.0.1",
"svelte": "^4.2.10",
"@astrojs/svelte": "^5.0.3",
"@astrojs/vue": "^4.0.8",
"@types/chai": "^4.3.5",
"@types/mocha": "^10.0.1",
"@types/node": "^18.17.8",
"@volar/test-utils": "~2.0.2",
"astro": "^4.1.0",
"astro": "^4.3.5",
"chai": "^4.3.7",
"mocha": "^10.2.0",
"tsx": "^3.12.7",
Expand Down
6 changes: 3 additions & 3 deletions packages/language-server/test/check/check.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os from 'node:os';
import path from 'node:path';
import { expect } from 'chai';
import { before, describe, it } from 'mocha';
import os from 'node:os';
import path from 'node:path';
import { AstroCheck, CheckResult } from '../../dist/check.js';

describe('AstroCheck', async () => {
Expand Down Expand Up @@ -43,7 +43,7 @@ describe('AstroCheck', async () => {
});

it('Can return the total amount of files checked', async () => {
expect(result.fileChecked).to.equal(5);
expect(result.fileChecked).to.equal(6);
});

it('Can return the status of the check', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script>
let name = 'world';
</script>

<h1>Hello {name}!</h1>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<template></template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
import SvelteComponent from './Component.svelte';
import VueComponent from './Component.vue';
---

<SvelteComponent />
<VueComponent />
19 changes: 5 additions & 14 deletions packages/language-server/test/typescript/diagnostics.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as path from 'path';
import {
type Diagnostic,
DiagnosticSeverity,
FullDocumentDiagnosticReport,
Range,
type Diagnostic,
} from '@volar/language-server';
import { expect } from 'chai';
import { before, describe, it } from 'mocha';
import { type LanguageServer, getLanguageServer } from '../server.js';
import * as path from 'path';
import { getLanguageServer, type LanguageServer } from '../server.js';

describe('TypeScript - Diagnostics', async () => {
let languageServer: LanguageServer;
Expand Down Expand Up @@ -62,7 +62,7 @@ describe('TypeScript - Diagnostics', async () => {
const diagnostics = (await languageServer.handle.sendDocumentDiagnosticRequest(
document.uri
)) as FullDocumentDiagnosticReport;
expect(diagnostics.items).length(2);
expect(diagnostics.items).length(1);

diagnostics.items = diagnostics.items.map((diag) => ({ ...diag, data: {} }));
expect(diagnostics.items).to.deep.equal([
Expand All @@ -74,16 +74,7 @@ describe('TypeScript - Diagnostics', async () => {
range: Range.create(5, 5, 5, 16),
severity: DiagnosticSeverity.Error,
source: 'ts',
},
{
code: 2307,
data: {},
message:
"Cannot find module 'astro:content' or its corresponding type declarations.\n\nIf you're using content collections, make sure to run `astro dev`, `astro build` or `astro sync` to first generate the types so you can import from them. If you already ran one of those commands, restarting the language server might be necessary in order for the change to take effect.",
range: Range.create(1, 31, 1, 46),
severity: DiagnosticSeverity.Error,
source: 'ts',
},
}
]);
});

Expand Down
Loading

0 comments on commit 16756fb

Please sign in to comment.