@@ -6,14 +6,16 @@ export const test: Test = async ({ Command, Editor, expect, FileSystem, Locator,
66 // arrange
77 const fixtureUrl = import . meta. resolve ( '../fixtures/diagnostics-unused' )
88 const workspaceUrl = await FileSystem . loadFixture ( fixtureUrl )
9- await Workspace . setPath ( workspaceUrl )
9+ await Workspace . setUri ( workspaceUrl )
1010 await Settings . update ( { 'editor.diagnostics' : true } )
1111
1212 // act
1313 await Main . openUri ( `${ workspaceUrl } /src/test.ts` )
1414 await Command . execute ( 'Editor.waitForDiagnostics' )
1515
1616 // assert
17+ const diagnostics = Locator ( '.Diagnostic' )
18+ const unnecessaryTokens = Locator ( '.EditorTokenUnnecessary' )
1719 const expectedDiagnostics = [
1820 {
1921 code : 6133 ,
@@ -23,10 +25,24 @@ export const test: Test = async ({ Command, Editor, expect, FileSystem, Locator,
2325 message : "'unused' is declared but its value is never read." ,
2426 rowIndex : 1 ,
2527 source : 'ts' ,
28+ tags : [ 1 ] ,
2629 type : 'warning' ,
2730 uri : `${ workspaceUrl } /src/test.ts` ,
2831 } ,
2932 ] as const
30- await expect ( Locator ( '.Diagnostic' ) ) . toHaveCount ( expectedDiagnostics . length )
33+ await expect ( diagnostics ) . toHaveCount ( expectedDiagnostics . length )
3134 await Editor . shouldHaveDiagnostics ( expectedDiagnostics )
35+ await expect ( unnecessaryTokens ) . toHaveText ( 'unused' )
36+
37+ // Make the variable used and verify the unnecessary styling is removed without reopening the file.
38+ await Editor . setText ( 'export const fixture = true\nconst unused = 1\nvoid unused\n\nexport {}' )
39+ await Command . execute ( 'Editor.waitForDiagnostics' )
40+ await Editor . shouldHaveDiagnostics ( [ ] )
41+ await expect ( unnecessaryTokens ) . toHaveCount ( 0 )
42+
43+ // Restore the unused declaration and verify the styling returns.
44+ await Editor . setText ( 'export const fixture = true\nconst unused = 1\n\nexport {}' )
45+ await Command . execute ( 'Editor.waitForDiagnostics' )
46+ await Editor . shouldHaveDiagnostics ( expectedDiagnostics )
47+ await expect ( unnecessaryTokens ) . toHaveText ( 'unused' )
3248}
0 commit comments