From 460db8e05f8ca0eeb623e2248a682ab4c5c372c5 Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Thu, 22 Aug 2024 18:03:16 +0200 Subject: [PATCH] fix tests --- .../svelte/features/getDiagnostics.test.ts | 98 ++++++++++--------- 1 file changed, 52 insertions(+), 46 deletions(-) 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 0c3856a6b..e4e72b497 100644 --- a/packages/language-server/test/plugins/svelte/features/getDiagnostics.test.ts +++ b/packages/language-server/test/plugins/svelte/features/getDiagnostics.test.ts @@ -483,60 +483,66 @@ describe('SveltePlugin#getDiagnostics', () => { const { plugin, document } = setupFromFile('diagnostics-module.svelte'); const diagnostics = await plugin.getDiagnostics(document); - assert.deepStrictEqual(diagnostics, [ - { - 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' - : '$: has no effect in a module script', - severity: 2, - source: 'svelte', - code: isSvelte5Plus - ? 'reactive_declaration_invalid_placement' - : 'module-script-reactive-declaration' - } - ]); + assert.deepStrictEqual( + diagnostics.filter((d) => d.code !== 'script_context_deprecated'), + [ + { + 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' + : '$: has no effect in a module script', + severity: 2, + source: 'svelte', + code: isSvelte5Plus + ? 'reactive_declaration_invalid_placement' + : 'module-script-reactive-declaration' + } + ] + ); }); it('should correctly determine diagnostic position for script when theres also context="module"', async () => { const { plugin, document } = setupFromFile('diagnostics-module-and-instance.svelte'); const diagnostics = await plugin.getDiagnostics(document); - assert.deepStrictEqual(diagnostics, [ - { - 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`", - range: { - start: { - line: 5, - character: 13 + assert.deepStrictEqual( + diagnostics.filter((d) => d.code !== 'script_context_deprecated'), + [ + { + 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`", + range: { + start: { + line: 5, + character: 13 + }, + end: { + line: 5, + character: isSvelte5Plus ? 20 : 27 + } }, - end: { - line: 5, - character: isSvelte5Plus ? 20 : 27 - } + severity: 2, + source: 'svelte' }, - severity: 2, - source: 'svelte' - }, - { - 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`", - range: { - start: { - line: 6, - character: 13 + { + 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`", + range: { + start: { + line: 6, + character: 13 + }, + end: { + line: 6, + character: isSvelte5Plus ? 20 : 27 + } }, - end: { - line: 6, - character: isSvelte5Plus ? 20 : 27 - } - }, - severity: 2, - source: 'svelte' - } - ]); + severity: 2, + source: 'svelte' + } + ] + ); }); });