From 96f0af5e98a1f0da50812b358163896095f58cd0 Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Wed, 11 Dec 2024 00:00:44 +0100 Subject: [PATCH] chore: fix tests for Svelte 5 --- .../test/plugins/svelte/SveltePlugin.test.ts | 10 ++++++---- .../plugins/svelte/features/getDiagnostics.test.ts | 11 +++++++---- .../fixtures/parser-error/expected_svelte_5.json | 2 +- .../svelte-element-error/expected_svelte_5.json | 2 +- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/packages/language-server/test/plugins/svelte/SveltePlugin.test.ts b/packages/language-server/test/plugins/svelte/SveltePlugin.test.ts index 1e57caea1..911e195e8 100644 --- a/packages/language-server/test/plugins/svelte/SveltePlugin.test.ts +++ b/packages/language-server/test/plugins/svelte/SveltePlugin.test.ts @@ -39,7 +39,7 @@ describe('Svelte Plugin', () => { const diagnostic = Diagnostic.create( Range.create(1, 0, 1, 21), isSvelte5Plus - ? '`` element should have an alt attribute' + ? '`` element should have an alt attribute\nhttps://svelte.dev/e/a11y_missing_attribute' : 'A11y: element should have an alt attribute', DiagnosticSeverity.Warning, isSvelte5Plus ? 'a11y_missing_attribute' : 'a11y-missing-attribute', @@ -54,10 +54,12 @@ describe('Svelte Plugin', () => { const diagnostics = await plugin.getDiagnostics(document); const diagnostic = Diagnostic.create( - Range.create(0, 10, 0, 18), - isSvelte5Plus ? 'Can only bind to state or props' : 'whatever is not declared', + Range.create(0, isSvelte5Plus ? 5 : 10, 0, 18), + isSvelte5Plus + ? '`bind:whatever` is not a valid binding\nhttps://svelte.dev/e/bind_invalid_name' + : 'whatever is not declared', DiagnosticSeverity.Error, - isSvelte5Plus ? 'bind_invalid_value' : 'binding-undeclared', + isSvelte5Plus ? 'bind_invalid_name' : 'binding-undeclared', 'svelte' ); diff --git a/packages/language-server/test/plugins/svelte/features/getDiagnostics.test.ts b/packages/language-server/test/plugins/svelte/features/getDiagnostics.test.ts index e4e72b497..b41958228 100644 --- a/packages/language-server/test/plugins/svelte/features/getDiagnostics.test.ts +++ b/packages/language-server/test/plugins/svelte/features/getDiagnostics.test.ts @@ -471,7 +471,8 @@ describe('SveltePlugin#getDiagnostics', () => { { range: { start: { line: 1, character: 15 }, end: { line: 1, character: 27 } }, message: - "Component has unused export property 'name'. If it is for external reference only, please consider using `export const name`", + "Component has unused export property 'name'. If it is for external reference only, please consider using `export const name`" + + (isSvelte5Plus ? '\nhttps://svelte.dev/e/export_let_unused' : ''), severity: 2, source: 'svelte', code: isSvelte5Plus ? 'export_let_unused' : 'unused-export-let' @@ -489,7 +490,7 @@ describe('SveltePlugin#getDiagnostics', () => { { range: { start: { line: 1, character: 4 }, end: { line: 1, character: 26 } }, message: isSvelte5Plus - ? 'Reactive declarations only exist at the top level of the instance script' + ? 'Reactive declarations only exist at the top level of the instance script\nhttps://svelte.dev/e/reactive_declaration_invalid_placement' : '$: has no effect in a module script', severity: 2, source: 'svelte', @@ -511,7 +512,8 @@ describe('SveltePlugin#getDiagnostics', () => { { code: isSvelte5Plus ? 'export_let_unused' : 'unused-export-let', message: - "Component has unused export property 'unused1'. If it is for external reference only, please consider using `export const unused1`", + "Component has unused export property 'unused1'. If it is for external reference only, please consider using `export const unused1`" + + (isSvelte5Plus ? '\nhttps://svelte.dev/e/export_let_unused' : ''), range: { start: { line: 5, @@ -528,7 +530,8 @@ describe('SveltePlugin#getDiagnostics', () => { { code: isSvelte5Plus ? 'export_let_unused' : 'unused-export-let', message: - "Component has unused export property 'unused2'. If it is for external reference only, please consider using `export const unused2`", + "Component has unused export property 'unused2'. If it is for external reference only, please consider using `export const unused2`" + + (isSvelte5Plus ? '\nhttps://svelte.dev/e/export_let_unused' : ''), range: { start: { line: 6, diff --git a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/parser-error/expected_svelte_5.json b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/parser-error/expected_svelte_5.json index c0fcc5b6d..65bcc0afb 100644 --- a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/parser-error/expected_svelte_5.json +++ b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/parser-error/expected_svelte_5.json @@ -3,7 +3,7 @@ "range": { "start": { "line": 1, "character": 0 }, "end": { "line": 1, "character": 0 } }, "severity": 1, "source": "js", - "message": "A component can have a single top-level `