Skip to content

Commit 390e632

Browse files
RyanCavanaughbillti
authored andcommitted
Add unit test
(cherry picked from commit ff09479) (cherry picked from commit c66a535)
1 parent 5b7a099 commit 390e632

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,41 @@ namespace ts.projectSystem {
10071007
checkProjectRootFiles(projectService.configuredProjects[0], [commonFile1.path, commonFile2.path]);
10081008
});
10091009

1010+
it("should disable features when the files are too large", () => {
1011+
const file1 = {
1012+
path: "/a/b/f1.js",
1013+
content: "let x =1;",
1014+
fileSize: 10 * 1024 * 1024
1015+
};
1016+
const file2 = {
1017+
path: "/a/b/f2.js",
1018+
content: "let y =1;",
1019+
fileSize: 6 * 1024 * 1024
1020+
};
1021+
const file3 = {
1022+
path: "/a/b/f3.js",
1023+
content: "let y =1;",
1024+
fileSize: 6 * 1024 * 1024
1025+
};
1026+
1027+
const proj1name = "proj1", proj2name = "proj2", proj3name = "proj3";
1028+
1029+
const host = createServerHost([file1, file2, file3]);
1030+
const projectService = createProjectService(host);
1031+
1032+
projectService.openExternalProject({ rootFiles: toExternalFiles([file1.path]), options: {}, projectFileName: proj1name });
1033+
const proj1 = projectService.findProject(proj1name);
1034+
assert.isTrue(proj1.languageServiceEnabled);
1035+
1036+
projectService.openExternalProject({ rootFiles: toExternalFiles([file2.path]), options: {}, projectFileName: proj2name });
1037+
const proj2 = projectService.findProject(proj2name);
1038+
assert.isTrue(proj2.languageServiceEnabled);
1039+
1040+
projectService.openExternalProject({ rootFiles: toExternalFiles([file3.path]), options: {}, projectFileName: proj3name });
1041+
const proj3 = projectService.findProject(proj3name);
1042+
assert.isFalse(proj3.languageServiceEnabled);
1043+
});
1044+
10101045
it("should use only one inferred project if 'useOneInferredProject' is set", () => {
10111046
const file1 = {
10121047
path: "/a/b/main.ts",

0 commit comments

Comments
 (0)