Skip to content

Commit 7736ea4

Browse files
committed
Add tests that create relative path even though the script info isnt dynamic
1 parent b534fb4 commit 7736ea4

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

src/testRunner/unittests/tsserverProjectSystem.ts

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3301,6 +3301,23 @@ namespace ts.projectSystem {
33013301
});
33023302
});
33033303

3304+
it("dynamic file with reference paths external project", () => {
3305+
const file: File = {
3306+
path: "^walkThroughSnippet:/Users/UserName/projects/someProject/out/someFile#1.js",
3307+
content: `/// <reference path="../../../../../../typings/@epic/Core.d.ts" />
3308+
/// <reference path="../../../../../../typings/@epic/Shell.d.ts" />
3309+
var x = 10;`
3310+
};
3311+
const host = createServerHost([libFile]);
3312+
const projectService = createProjectService(host);
3313+
projectService.openClientFile(file.path, file.content);
3314+
3315+
projectService.checkNumberOfProjects({ inferredProjects: 1 });
3316+
const project = projectService.inferredProjects[0];
3317+
checkProjectRootFiles(project, [file.path]);
3318+
checkProjectActualFiles(project, [file.path, libFile.path]);
3319+
});
3320+
33043321
it("files opened, closed affecting multiple projects", () => {
33053322
const file: File = {
33063323
path: "/a/b/projects/config/file.ts",
@@ -3893,8 +3910,8 @@ namespace ts.projectSystem {
38933910
command: server.CommandNames.Open,
38943911
arguments: {
38953912
file: untitledFile,
3896-
fileContent: "",
3897-
scriptKindName: "JS",
3913+
fileContent: `/// <reference path="../../../../../../typings/@epic/Core.d.ts" />`,
3914+
scriptKindName: "TS",
38983915
projectRootPath: useProjectRoot ? folderPath : undefined
38993916
}
39003917
});
@@ -10772,16 +10789,16 @@ fn5();`
1077210789
const untitledFile = "untitled:^Untitled-1";
1077310790
executeSessionRequestNoResponse<protocol.OpenRequest>(session, protocol.CommandTypes.Open, {
1077410791
file: untitledFile,
10775-
fileContent: "let foo = 1;\nfooo/**/",
10792+
fileContent: `/// <reference path="../../../../../../typings/@epic/Core.d.ts" />\nlet foo = 1;\nfooo/**/`,
1077610793
scriptKindName: "TS",
1077710794
projectRootPath: "/proj",
1077810795
});
1077910796

1078010797
const response = executeSessionRequest<protocol.CodeFixRequest, protocol.CodeFixResponse>(session, protocol.CommandTypes.GetCodeFixes, {
1078110798
file: untitledFile,
10782-
startLine: 2,
10799+
startLine: 3,
1078310800
startOffset: 1,
10784-
endLine: 2,
10801+
endLine: 3,
1078510802
endOffset: 5,
1078610803
errorCodes: [Diagnostics.Cannot_find_name_0_Did_you_mean_1.code],
1078710804
});
@@ -10794,8 +10811,8 @@ fn5();`
1079410811
changes: [{
1079510812
fileName: untitledFile,
1079610813
textChanges: [{
10797-
start: { line: 2, offset: 1 },
10798-
end: { line: 2, offset: 5 },
10814+
start: { line: 3, offset: 1 },
10815+
end: { line: 3, offset: 5 },
1079910816
newText: "foo",
1080010817
}],
1080110818
}],

0 commit comments

Comments
 (0)