Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dummdidumm committed Aug 22, 2024
1 parent fe60da4 commit 460db8e
Showing 1 changed file with 52 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
]
);
});
});

0 comments on commit 460db8e

Please sign in to comment.