|
6 | 6 | baselineTsserverLogs,
|
7 | 7 | closeFilesForSession,
|
8 | 8 | openFilesForSession,
|
| 9 | + projectInfoForSession, |
9 | 10 | TestSession,
|
10 | 11 | verifyGetErrRequest,
|
11 | 12 | } from "../helpers/tsserver.js";
|
@@ -152,6 +153,7 @@ describe("unittests:: tsserver:: configuredProjects::", () => {
|
152 | 153 | const { host, session, commonFile1, commonFile2, configFile } = setup(parentOrSiblingConfigFile);
|
153 | 154 |
|
154 | 155 | openFilesForSession([commonFile1], session);
|
| 156 | + projectInfoForSession(session, commonFile1); |
155 | 157 |
|
156 | 158 | session.logger.log("1: When config file is deleted and then another file is opened");
|
157 | 159 | // remove the tsconfig file
|
@@ -236,13 +238,35 @@ describe("unittests:: tsserver:: configuredProjects::", () => {
|
236 | 238 | openFilesForSession([commonFile1, commonFile2], session);
|
237 | 239 | closeFilesForSession([commonFile2], session);
|
238 | 240 | openFilesForSession([{ file: "/user/username/projects/random/random.ts", content: "export const y = 10;" }], session);
|
| 241 | + closeFilesForSession(["/user/username/projects/random/random.ts"], session); |
| 242 | + |
| 243 | + session.logger.log("7: When config file is deleted and then another file is opened and projectInfo"); |
| 244 | + // remove the tsconfig file |
| 245 | + host.deleteFile(configFile.path); |
| 246 | + openFilesForSession([commonFile2], session); |
| 247 | + |
| 248 | + projectInfoForSession(session, commonFile1); |
| 249 | + projectInfoForSession(session, commonFile2); |
| 250 | + |
| 251 | + // Add a tsconfig file |
| 252 | + host.writeFile(configFile.path, configFile.content); |
| 253 | + host.runQueuedTimeoutCallbacks(); |
| 254 | + |
| 255 | + session.logger.log("8: When both files are open and config file is deleted and projectInfo"); |
| 256 | + // remove the tsconfig file |
| 257 | + host.deleteFile(configFile.path); |
| 258 | + host.runQueuedTimeoutCallbacks(); |
| 259 | + |
| 260 | + projectInfoForSession(session, commonFile1); |
| 261 | + projectInfoForSession(session, commonFile2); |
239 | 262 |
|
240 | 263 | baselineTsserverLogs("configuredProjects", `add and then remove a config file ${scenario}`, session);
|
241 | 264 | });
|
242 | 265 |
|
243 | 266 | it(`add and then remove a config file ${scenario} and file from first config is not open`, () => {
|
244 | 267 | const { host, session, commonFile2, configFile } = setup(parentOrSiblingConfigFile);
|
245 | 268 | openFilesForSession([commonFile2], session);
|
| 269 | + projectInfoForSession(session, commonFile2); |
246 | 270 |
|
247 | 271 | session.logger.log("1: When config file is deleted");
|
248 | 272 | // remove the tsconfig file
|
@@ -271,6 +295,27 @@ describe("unittests:: tsserver:: configuredProjects::", () => {
|
271 | 295 | closeFilesForSession([commonFile2], session);
|
272 | 296 | openFilesForSession([{ file: "/user/username/projects/random/random.ts", content: "export const y = 10;" }], session);
|
273 | 297 |
|
| 298 | + // Add a tsconfig file |
| 299 | + host.writeFile(configFile.path, configFile.content); |
| 300 | + host.runQueuedTimeoutCallbacks(); |
| 301 | + closeFilesForSession(["/user/username/projects/random/random.ts"], session); |
| 302 | + openFilesForSession([commonFile2], session); |
| 303 | + |
| 304 | + session.logger.log("3: When config file is deleted and projectInfo"); |
| 305 | + // remove the tsconfig file |
| 306 | + host.deleteFile(configFile.path); |
| 307 | + host.runQueuedTimeoutCallbacks(); |
| 308 | + projectInfoForSession(session, commonFile2); |
| 309 | + |
| 310 | + // Add a tsconfig file |
| 311 | + host.writeFile(configFile.path, configFile.content); |
| 312 | + host.runQueuedTimeoutCallbacks(); |
| 313 | + |
| 314 | + session.logger.log("4: Check when file is closed when config file is deleted and projectInfo"); |
| 315 | + // remove the tsconfig file |
| 316 | + host.deleteFile(configFile.path); |
| 317 | + projectInfoForSession(session, commonFile2); |
| 318 | + |
274 | 319 | baselineTsserverLogs("configuredProjects", `add and then remove a config file ${scenario} and file from first config is not open`, session);
|
275 | 320 | });
|
276 | 321 | }
|
@@ -995,7 +1040,7 @@ foo();`,
|
995 | 1040 | endOffset: 1,
|
996 | 1041 | },
|
997 | 1042 | });
|
998 |
| - session.logger.log(`Default project for file: ${fooDts}: ${session.getProjectService().tryGetDefaultProjectForFile(ts.server.toNormalizedPath(fooDts))?.projectName}`); |
| 1043 | + projectInfoForSession(session, fooDts); |
999 | 1044 | baselineTsserverLogs("configuredProjects", "when default configured project does not contain the file", session);
|
1000 | 1045 | });
|
1001 | 1046 |
|
|
0 commit comments