Skip to content

Commit bb05381

Browse files
committed
Update new tests from master
1 parent 16cfcc4 commit bb05381

File tree

1 file changed

+90
-89
lines changed

1 file changed

+90
-89
lines changed

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 90 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,23 +1238,23 @@ namespace ts.projectSystem {
12381238
checkNumberOfInferredProjects(projectService, 0);
12391239
});
12401240

1241-
it("external project for dynamic file", () => {
1242-
const externalProjectName = "^ScriptDocument1 file1.ts";
1243-
const externalFiles = toExternalFiles(["^ScriptDocument1 file1.ts"]);
1244-
const host = createServerHost([]);
1245-
const projectService = createProjectService(host);
1246-
projectService.openExternalProject({
1247-
rootFiles: externalFiles,
1248-
options: {},
1249-
projectFileName: externalProjectName
1250-
});
1241+
it("external project for dynamic file", () => {
1242+
const externalProjectName = "^ScriptDocument1 file1.ts";
1243+
const externalFiles = toExternalFiles(["^ScriptDocument1 file1.ts"]);
1244+
const host = createServerHost([]);
1245+
const projectService = createProjectService(host);
1246+
projectService.openExternalProject({
1247+
rootFiles: externalFiles,
1248+
options: {},
1249+
projectFileName: externalProjectName
1250+
});
12511251

1252-
checkNumberOfExternalProjects(projectService, 1);
1253-
checkNumberOfInferredProjects(projectService, 0);
1252+
checkNumberOfExternalProjects(projectService, 1);
1253+
checkNumberOfInferredProjects(projectService, 0);
12541254

1255-
externalFiles[0].content = "let x =1;";
1256-
projectService.applyChangesInOpenFiles(externalFiles, [], []);
1257-
});
1255+
externalFiles[0].content = "let x =1;";
1256+
projectService.applyChangesInOpenFiles(externalFiles, [], []);
1257+
});
12581258

12591259
it("external project that included config files", () => {
12601260
const file1 = {
@@ -1356,13 +1356,13 @@ namespace ts.projectSystem {
13561356
service.checkNumberOfProjects({ externalProjects: 1 });
13571357
checkProjectActualFiles(service.externalProjects[0], [f1.path, f2.path, fakes.FakeServerHost.libPath]);
13581358

1359-
const completions1 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 2, { includeExternalModuleExports: false, includeInsertTextCompletions: false });
1359+
const completions1 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 2, { includeExternalModuleExports: false, includeInsertTextCompletions: false });
13601360
// should contain completions for string
13611361
assert.isTrue(completions1.entries.some(e => e.name === "charAt"), "should contain 'charAt'");
13621362
assert.isFalse(completions1.entries.some(e => e.name === "toExponential"), "should not contain 'toExponential'");
13631363

13641364
service.closeClientFile(f2.path);
1365-
const completions2 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 2, { includeExternalModuleExports: false, includeInsertTextCompletions: false });
1365+
const completions2 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 2, { includeExternalModuleExports: false, includeInsertTextCompletions: false });
13661366
// should contain completions for string
13671367
assert.isFalse(completions2.entries.some(e => e.name === "charAt"), "should not contain 'charAt'");
13681368
assert.isTrue(completions2.entries.some(e => e.name === "toExponential"), "should contain 'toExponential'");
@@ -1560,7 +1560,8 @@ namespace ts.projectSystem {
15601560
const proj = projectService.externalProjects[0];
15611561
assert.deepEqual(proj.getFileNames(/*excludeFilesFromExternalLibraries*/ true), [file1.path]);
15621562
assert.deepEqual(proj.getTypeAcquisition().include, ["duck-types"]);
1563-
} finally {
1563+
}
1564+
finally {
15641565
projectService.resetSafeList();
15651566
}
15661567
});
@@ -1998,7 +1999,7 @@ namespace ts.projectSystem {
19981999

19992000
// Check identifiers defined in HTML content are available in .ts file
20002001
const project = configuredProjectAt(projectService, 0);
2001-
let completions = project.getLanguageService().getCompletionsAtPosition(file1.path, 1, { includeExternalModuleExports: false, includeInsertTextCompletions: false });
2002+
let completions = project.getLanguageService().getCompletionsAtPosition(file1.path, 1, { includeExternalModuleExports: false, includeInsertTextCompletions: false });
20022003
assert(completions && completions.entries[0].name === "hello", `expected entry hello to be in completion list`);
20032004

20042005
// Close HTML file
@@ -2012,7 +2013,7 @@ namespace ts.projectSystem {
20122013
checkProjectActualFiles(configuredProjectAt(projectService, 0), [file1.path, file2.path, config.path]);
20132014

20142015
// Check identifiers defined in HTML content are not available in .ts file
2015-
completions = project.getLanguageService().getCompletionsAtPosition(file1.path, 5, { includeExternalModuleExports: false, includeInsertTextCompletions: false });
2016+
completions = project.getLanguageService().getCompletionsAtPosition(file1.path, 5, { includeExternalModuleExports: false, includeInsertTextCompletions: false });
20162017
assert(completions && completions.entries[0].name !== "hello", `unexpected hello entry in completion list`);
20172018
});
20182019

@@ -2171,7 +2172,7 @@ namespace ts.projectSystem {
21712172

21722173
const scriptInfo = project.getScriptInfo(file1.path);
21732174
const snap = scriptInfo.getSnapshot();
2174-
const actualText = getSnapshotText(snap);
2175+
const actualText = getSnapshotText(snap);
21752176
assert.equal(actualText, "", `expected content to be empty string, got "${actualText}"`);
21762177

21772178
projectService.openClientFile(file1.path, `var x = 1;`);
@@ -2183,7 +2184,7 @@ namespace ts.projectSystem {
21832184
projectService.closeClientFile(file1.path);
21842185

21852186
const scriptInfo2 = project.getScriptInfo(file1.path);
2186-
const actualText2 = getSnapshotText(scriptInfo2.getSnapshot());
2187+
const actualText2 = getSnapshotText(scriptInfo2.getSnapshot());
21872188
assert.equal(actualText2, "", `expected content to be empty string, got "${actualText2}"`);
21882189
});
21892190

@@ -4298,31 +4299,31 @@ namespace ts.projectSystem {
42984299
projectService.checkNumberOfProjects({ configuredProjects: 0, inferredProjects: 1 });
42994300
});
43004301

4301-
it("should tolerate invalid include files that start in subDirectory", () => {
4302-
const projectFolder = "/user/username/projects/myproject";
4303-
const f = {
4304-
path: `${projectFolder}/src/server/index.ts`,
4305-
content: "let x = 1"
4306-
};
4307-
const config = {
4308-
path: `${projectFolder}/src/server/tsconfig.json`,
4309-
content: JSON.stringify({
4310-
compiler: {
4311-
module: "commonjs",
4312-
outDir: "../../build"
4313-
},
4314-
include: [
4315-
"../src/**/*.ts"
4316-
]
4317-
})
4318-
};
4319-
const host = createServerHost([f, config, libFile], { dos: true });
4320-
const projectService = createProjectService(host);
4302+
it("should tolerate invalid include files that start in subDirectory", () => {
4303+
const projectFolder = "/user/username/projects/myproject";
4304+
const f = {
4305+
path: `${projectFolder}/src/server/index.ts`,
4306+
content: "let x = 1"
4307+
};
4308+
const config = {
4309+
path: `${projectFolder}/src/server/tsconfig.json`,
4310+
content: JSON.stringify({
4311+
compiler: {
4312+
module: "commonjs",
4313+
outDir: "../../build"
4314+
},
4315+
include: [
4316+
"../src/**/*.ts"
4317+
]
4318+
})
4319+
};
4320+
const host = createServerHost([f, config, libFile], { dos: true });
4321+
const projectService = createProjectService(host);
43214322

4322-
projectService.openClientFile(f.path);
4323-
// Since no file from the configured project is open, it would be closed immediately
4324-
projectService.checkNumberOfProjects({ configuredProjects: 0, inferredProjects: 1 });
4325-
});
4323+
projectService.openClientFile(f.path);
4324+
// Since no file from the configured project is open, it would be closed immediately
4325+
projectService.checkNumberOfProjects({ configuredProjects: 0, inferredProjects: 1 });
4326+
});
43264327
});
43274328

43284329
describe("reload", () => {
@@ -4357,7 +4358,7 @@ namespace ts.projectSystem {
43574358
// verify content
43584359
const projectServiice = session.getProjectService();
43594360
const snap1 = projectServiice.getScriptInfo(f1.path).getSnapshot();
4360-
assert.equal(getSnapshotText(snap1), tmp.content, "content should be equal to the content of temp file");
4361+
assert.equal(getSnapshotText(snap1), tmp.content, "content should be equal to the content of temp file");
43614362

43624363
// reload from original file file
43634364
session.executeCommand(<server.protocol.ReloadRequest>{
@@ -4369,7 +4370,7 @@ namespace ts.projectSystem {
43694370

43704371
// verify content
43714372
const snap2 = projectServiice.getScriptInfo(f1.path).getSnapshot();
4372-
assert.equal(getSnapshotText(snap2), f1.content, "content should be equal to the content of original file");
4373+
assert.equal(getSnapshotText(snap2), f1.content, "content should be equal to the content of original file");
43734374

43744375
});
43754376

@@ -4459,7 +4460,7 @@ namespace ts.projectSystem {
44594460

44604461
function checkScriptInfoContents(contentsOfInfo: string, captionForContents: string) {
44614462
const snap = info.getSnapshot();
4462-
assert.equal(getSnapshotText(snap), contentsOfInfo, "content should be equal to " + captionForContents);
4463+
assert.equal(getSnapshotText(snap), contentsOfInfo, "content should be equal to " + captionForContents);
44634464
}
44644465
});
44654466
});
@@ -6703,7 +6704,7 @@ namespace ts.projectSystem {
67036704
});
67046705
});
67056706

6706-
describe("tsserverProjectSystem typingsInstaller on inferred Project", () => {
6707+
describe("typingsInstaller on inferred Project", () => {
67076708
it("when projectRootPath is provided", () => {
67086709
const projects = "/users/username/projects";
67096710
const projectRootPath = `${projects}/san2`;
@@ -6775,7 +6776,7 @@ namespace ts.projectSystem {
67756776
});
67766777
});
67776778

6778-
describe("tsserverProjectSystem with symLinks", () => {
6779+
describe("with symLinks", () => {
67796780
it("rename in common file renames all project", () => {
67806781
const projects = "/users/username/projects";
67816782
const folderA = `${projects}/a`;
@@ -6882,49 +6883,49 @@ namespace ts.projectSystem {
68826883
});
68836884
});
68846885
});
6885-
});
68866886

6887-
describe("tsserverProjectSystem forceConsistentCasingInFileNames", () => {
6888-
it("works when extends is specified with a case insensitive file system", () => {
6889-
const rootPath = "/Users/username/dev/project";
6890-
const file1: FileOrFolder = {
6891-
path: `${rootPath}/index.ts`,
6892-
content: 'import {x} from "file2";',
6893-
};
6894-
const file2: FileOrFolder = {
6895-
path: `${rootPath}/file2.js`,
6896-
content: "",
6897-
};
6898-
const file2Dts: FileOrFolder = {
6899-
path: `${rootPath}/types/file2/index.d.ts`,
6900-
content: "export declare const x: string;",
6901-
};
6902-
const tsconfigAll: FileOrFolder = {
6903-
path: `${rootPath}/tsconfig.all.json`,
6904-
content: JSON.stringify({
6905-
compilerOptions: {
6906-
baseUrl: ".",
6907-
paths: { file2: ["./file2.js"] },
6908-
typeRoots: ["./types"],
6909-
forceConsistentCasingInFileNames: true,
6910-
},
6911-
}),
6912-
};
6913-
const tsconfig: FileOrFolder = {
6914-
path: `${rootPath}/tsconfig.json`,
6915-
content: JSON.stringify({ extends: "./tsconfig.all.json" }),
6916-
};
6887+
describe("forceConsistentCasingInFileNames", () => {
6888+
it("works when extends is specified with a case insensitive file system", () => {
6889+
const rootPath = "c:/Users/username/dev/project";
6890+
const file1: FileOrFolder = {
6891+
path: `${rootPath}/index.ts`,
6892+
content: 'import {x} from "file2";',
6893+
};
6894+
const file2: FileOrFolder = {
6895+
path: `${rootPath}/file2.js`,
6896+
content: "",
6897+
};
6898+
const file2Dts: FileOrFolder = {
6899+
path: `${rootPath}/types/file2/index.d.ts`,
6900+
content: "export declare const x: string;",
6901+
};
6902+
const tsconfigAll: FileOrFolder = {
6903+
path: `${rootPath}/tsconfig.all.json`,
6904+
content: JSON.stringify({
6905+
compilerOptions: {
6906+
baseUrl: ".",
6907+
paths: { file2: ["./file2.js"] },
6908+
typeRoots: ["./types"],
6909+
forceConsistentCasingInFileNames: true,
6910+
},
6911+
}),
6912+
};
6913+
const tsconfig: FileOrFolder = {
6914+
path: `${rootPath}/tsconfig.json`,
6915+
content: JSON.stringify({ extends: "./tsconfig.all.json" }),
6916+
};
69176917

6918-
const host = createServerHost([file1, file2, file2Dts, libFile, tsconfig, tsconfigAll], { useCaseSensitiveFileNames: false });
6919-
const session = createSession(host);
6918+
const host = createServerHost([file1, file2, file2Dts, libFile, tsconfig, tsconfigAll]);
6919+
const session = createSession(host);
69206920

6921-
openFilesForSession([file1], session);
6922-
const projectService = session.getProjectService();
6921+
openFilesForSession([file1.path], session);
6922+
const projectService = session.getProjectService();
69236923

6924-
checkNumberOfProjects(projectService, { configuredProjects: 1 });
6924+
checkNumberOfProjects(projectService, { configuredProjects: 1 });
69256925

6926-
const diagnostics = configuredProjectAt(projectService, 0).getLanguageService().getCompilerOptionsDiagnostics();
6927-
assert.deepEqual(diagnostics, []);
6926+
const diagnostics = configuredProjectAt(projectService, 0).getLanguageService().getCompilerOptionsDiagnostics();
6927+
assert.deepEqual(diagnostics, []);
6928+
});
69286929
});
69296930
});
69306931
}

0 commit comments

Comments
 (0)