@@ -8848,6 +8848,103 @@ export const x = 10;`
88488848 } ) ;
88498849 } ) ;
88508850
8851+ describe ( "tsserverProjectSystem syntax operations" , ( ) => {
8852+ function navBarFull ( session : TestSession , file : File ) {
8853+ return JSON . stringify ( session . executeCommandSeq < protocol . FileRequest > ( {
8854+ command : protocol . CommandTypes . NavBarFull ,
8855+ arguments : { file : file . path }
8856+ } ) . response ) ;
8857+ }
8858+
8859+ function openFile ( session : TestSession , file : File ) {
8860+ session . executeCommandSeq < protocol . OpenRequest > ( {
8861+ command : protocol . CommandTypes . Open ,
8862+ arguments : { file : file . path , fileContent : file . content }
8863+ } ) ;
8864+ }
8865+
8866+ it ( "works when file is removed and added with different content" , ( ) => {
8867+ const projectRoot = "/user/username/projects/myproject" ;
8868+ const app : File = {
8869+ path : `${ projectRoot } /app.ts` ,
8870+ content : "console.log('Hello world');"
8871+ } ;
8872+ const unitTest1 : File = {
8873+ path : `${ projectRoot } /unitTest1.ts` ,
8874+ content : `import assert = require('assert');
8875+
8876+ describe("Test Suite 1", () => {
8877+ it("Test A", () => {
8878+ assert.ok(true, "This shouldn't fail");
8879+ });
8880+
8881+ it("Test B", () => {
8882+ assert.ok(1 === 1, "This shouldn't fail");
8883+ assert.ok(false, "This should fail");
8884+ });
8885+ });`
8886+ } ;
8887+ const tsconfig : File = {
8888+ path : `${ projectRoot } /tsconfig.json` ,
8889+ content : "{}"
8890+ } ;
8891+ const files = [ app , libFile , tsconfig ] ;
8892+ const host = createServerHost ( files ) ;
8893+ const session = createSession ( host ) ;
8894+ const service = session . getProjectService ( ) ;
8895+ openFile ( session , app ) ;
8896+
8897+ checkNumberOfProjects ( service , { configuredProjects : 1 } ) ;
8898+ const project = service . configuredProjects . get ( tsconfig . path ) ! ;
8899+ const expectedFilesWithoutUnitTest1 = files . map ( f => f . path ) ;
8900+ checkProjectActualFiles ( project , expectedFilesWithoutUnitTest1 ) ;
8901+
8902+ host . writeFile ( unitTest1 . path , unitTest1 . content ) ;
8903+ host . runQueuedTimeoutCallbacks ( ) ;
8904+ const expectedFilesWithUnitTest1 = expectedFilesWithoutUnitTest1 . concat ( unitTest1 . path ) ;
8905+ checkProjectActualFiles ( project , expectedFilesWithUnitTest1 ) ;
8906+
8907+ openFile ( session , unitTest1 ) ;
8908+ checkProjectActualFiles ( project , expectedFilesWithUnitTest1 ) ;
8909+
8910+ const navBarResultUnitTest1 = navBarFull ( session , unitTest1 ) ;
8911+ host . removeFile ( unitTest1 . path ) ;
8912+ host . checkTimeoutQueueLengthAndRun ( 2 ) ;
8913+ checkProjectActualFiles ( project , expectedFilesWithoutUnitTest1 ) ;
8914+
8915+ session . executeCommandSeq < protocol . CloseRequest > ( {
8916+ command : protocol . CommandTypes . Close ,
8917+ arguments : { file : unitTest1 . path }
8918+ } ) ;
8919+ checkProjectActualFiles ( project , expectedFilesWithoutUnitTest1 ) ;
8920+
8921+ const unitTest1WithChangedContent : File = {
8922+ path : unitTest1 . path ,
8923+ content : `import assert = require('assert');
8924+
8925+ export function Test1() {
8926+ assert.ok(true, "This shouldn't fail");
8927+ };
8928+
8929+ export function Test2() {
8930+ assert.ok(1 === 1, "This shouldn't fail");
8931+ assert.ok(false, "This should fail");
8932+ };`
8933+ } ;
8934+ host . writeFile ( unitTest1 . path , unitTest1WithChangedContent . content ) ;
8935+ host . runQueuedTimeoutCallbacks ( ) ;
8936+ checkProjectActualFiles ( project , expectedFilesWithUnitTest1 ) ;
8937+
8938+ openFile ( session , unitTest1WithChangedContent ) ;
8939+ checkProjectActualFiles ( project , expectedFilesWithUnitTest1 ) ;
8940+ const sourceFile = project . getLanguageService ( ) . getNonBoundSourceFile ( unitTest1WithChangedContent . path ) ;
8941+ assert . strictEqual ( sourceFile . text , unitTest1WithChangedContent . content ) ;
8942+
8943+ const navBarResultUnitTest1WithChangedContent = navBarFull ( session , unitTest1WithChangedContent ) ;
8944+ assert . notStrictEqual ( navBarResultUnitTest1WithChangedContent , navBarResultUnitTest1 , "With changes in contents of unitTest file, we should see changed naviagation bar item result" ) ;
8945+ } ) ;
8946+ } ) ;
8947+
88518948 function makeSampleProjects ( ) {
88528949 const aTs : File = {
88538950 path : "/a/a.ts" ,
0 commit comments