Skip to content

Commit 5ecfa78

Browse files
committed
Few renames to distinguish between fs File and File in the test case to load in the VFS with watch
1 parent 618da24 commit 5ecfa78

8 files changed

+428
-408
lines changed

src/harness/unittests/compileOnSave.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace ts.projectSystem {
1111
}
1212

1313
describe("CompileOnSave affected list", () => {
14-
function sendAffectedFileRequestAndCheckResult(session: server.Session, request: server.protocol.Request, expectedFileList: { projectFileName: string, files: FileOrFolder[] }[]) {
14+
function sendAffectedFileRequestAndCheckResult(session: server.Session, request: server.protocol.Request, expectedFileList: { projectFileName: string, files: File[] }[]) {
1515
const response = session.executeCommand(request).response as server.protocol.CompileOnSaveAffectedFileListSingleProject[];
1616
const actualResult = response.sort((list1, list2) => compareStringsCaseSensitive(list1.projectFileName, list2.projectFileName));
1717
expectedFileList = expectedFileList.sort((list1, list2) => compareStringsCaseSensitive(list1.projectFileName, list2.projectFileName));
@@ -47,12 +47,12 @@ namespace ts.projectSystem {
4747
}
4848

4949
describe("for configured projects", () => {
50-
let moduleFile1: FileOrFolder;
51-
let file1Consumer1: FileOrFolder;
52-
let file1Consumer2: FileOrFolder;
53-
let moduleFile2: FileOrFolder;
54-
let globalFile3: FileOrFolder;
55-
let configFile: FileOrFolder;
50+
let moduleFile1: File;
51+
let file1Consumer1: File;
52+
let file1Consumer2: File;
53+
let moduleFile2: File;
54+
let globalFile3: File;
55+
let configFile: File;
5656
let changeModuleFile1ShapeRequest1: server.protocol.Request;
5757
let changeModuleFile1InternalRequest1: server.protocol.Request;
5858
// A compile on save affected file request using file1
@@ -225,7 +225,7 @@ namespace ts.projectSystem {
225225
openFilesForSession([moduleFile1], session);
226226
sendAffectedFileRequestAndCheckResult(session, moduleFile1FileListRequest, [{ projectFileName: configFile.path, files: [moduleFile1, file1Consumer1, file1Consumer2] }]);
227227

228-
const file1Consumer3: FileOrFolder = {
228+
const file1Consumer3: File = {
229229
path: "/a/b/file1Consumer3.ts",
230230
content: `import {Foo} from "./moduleFile1"; let y = Foo();`
231231
};
@@ -330,7 +330,7 @@ namespace ts.projectSystem {
330330
}`
331331
};
332332

333-
const configFile2: FileOrFolder = {
333+
const configFile2: File = {
334334
path: "/a/tsconfig.json",
335335
content: `{
336336
"compileOnSave": true
@@ -403,7 +403,7 @@ namespace ts.projectSystem {
403403
});
404404

405405
it("should return cascaded affected file list", () => {
406-
const file1Consumer1Consumer1: FileOrFolder = {
406+
const file1Consumer1Consumer1: File = {
407407
path: "/a/b/file1Consumer1Consumer1.ts",
408408
content: `import {y} from "./file1Consumer1";`
409409
};
@@ -428,13 +428,13 @@ namespace ts.projectSystem {
428428
});
429429

430430
it("should work fine for files with circular references", () => {
431-
const file1: FileOrFolder = {
431+
const file1: File = {
432432
path: "/a/b/file1.ts",
433433
content: `
434434
/// <reference path="./file2.ts" />
435435
export var t1 = 10;`
436436
};
437-
const file2: FileOrFolder = {
437+
const file2: File = {
438438
path: "/a/b/file2.ts",
439439
content: `
440440
/// <reference path="./file1.ts" />
@@ -450,11 +450,11 @@ namespace ts.projectSystem {
450450
});
451451

452452
it("should return results for all projects if not specifying projectFileName", () => {
453-
const file1: FileOrFolder = { path: "/a/b/file1.ts", content: "export var t = 10;" };
454-
const file2: FileOrFolder = { path: "/a/b/file2.ts", content: `import {t} from "./file1"; var t2 = 11;` };
455-
const file3: FileOrFolder = { path: "/a/c/file2.ts", content: `import {t} from "../b/file1"; var t3 = 11;` };
456-
const configFile1: FileOrFolder = { path: "/a/b/tsconfig.json", content: `{ "compileOnSave": true }` };
457-
const configFile2: FileOrFolder = { path: "/a/c/tsconfig.json", content: `{ "compileOnSave": true }` };
453+
const file1: File = { path: "/a/b/file1.ts", content: "export var t = 10;" };
454+
const file2: File = { path: "/a/b/file2.ts", content: `import {t} from "./file1"; var t2 = 11;` };
455+
const file3: File = { path: "/a/c/file2.ts", content: `import {t} from "../b/file1"; var t3 = 11;` };
456+
const configFile1: File = { path: "/a/b/tsconfig.json", content: `{ "compileOnSave": true }` };
457+
const configFile2: File = { path: "/a/c/tsconfig.json", content: `{ "compileOnSave": true }` };
458458

459459
const host = createServerHost([file1, file2, file3, configFile1, configFile2]);
460460
const session = createSession(host);
@@ -469,7 +469,7 @@ namespace ts.projectSystem {
469469
});
470470

471471
it("should detect removed code file", () => {
472-
const referenceFile1: FileOrFolder = {
472+
const referenceFile1: File = {
473473
path: "/a/b/referenceFile1.ts",
474474
content: `
475475
/// <reference path="./moduleFile1.ts" />
@@ -490,7 +490,7 @@ namespace ts.projectSystem {
490490
});
491491

492492
it("should detect non-existing code file", () => {
493-
const referenceFile1: FileOrFolder = {
493+
const referenceFile1: File = {
494494
path: "/a/b/referenceFile1.ts",
495495
content: `
496496
/// <reference path="./moduleFile2.ts" />

src/harness/unittests/organizeImports.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,11 +446,11 @@ import { React, Other } from "react";
446446
},
447447
reactLibFile);
448448

449-
function testOrganizeImports(testName: string, testFile: TestFSWithWatch.FileOrFolder, ...otherFiles: TestFSWithWatch.FileOrFolder[]) {
449+
function testOrganizeImports(testName: string, testFile: TestFSWithWatch.File, ...otherFiles: TestFSWithWatch.File[]) {
450450
it(testName, () => runBaseline(`organizeImports/${testName}.ts`, testFile, ...otherFiles));
451451
}
452452

453-
function runBaseline(baselinePath: string, testFile: TestFSWithWatch.FileOrFolder, ...otherFiles: TestFSWithWatch.FileOrFolder[]) {
453+
function runBaseline(baselinePath: string, testFile: TestFSWithWatch.File, ...otherFiles: TestFSWithWatch.File[]) {
454454
const { path: testPath, content: testContent } = testFile;
455455
const languageService = makeLanguageService(testFile, ...otherFiles);
456456
const changes = languageService.organizeImports({ type: "file", fileName: testPath }, testFormatOptions, defaultPreferences);
@@ -468,7 +468,7 @@ import { React, Other } from "react";
468468
});
469469
}
470470

471-
function makeLanguageService(...files: TestFSWithWatch.FileOrFolder[]) {
471+
function makeLanguageService(...files: TestFSWithWatch.File[]) {
472472
const host = projectSystem.createServerHost(files);
473473
const projectService = projectSystem.createProjectService(host, { useSingleInferredProject: true });
474474
projectService.setCompilerOptionsForInferredProjects({ jsx: files.some(f => f.path.endsWith("x")) ? JsxEmit.React : JsxEmit.None });
@@ -555,4 +555,4 @@ import { React, Other } from "react";
555555
}
556556
}
557557
});
558-
}
558+
}

src/harness/unittests/reuseProgramStructure.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ namespace ts {
884884
});
885885
});
886886

887-
type FileOrFolder = TestFSWithWatch.FileOrFolder;
887+
type File = TestFSWithWatch.File;
888888
import createTestSystem = TestFSWithWatch.createWatchedSystem;
889889
import libFile = TestFSWithWatch.libFile;
890890

@@ -920,22 +920,22 @@ namespace ts {
920920
verifyProgramIsUptoDate(program, fileNames, options);
921921
}
922922

923-
function verifyProgram(files: FileOrFolder[], rootFiles: string[], options: CompilerOptions, configFile: string) {
923+
function verifyProgram(files: File[], rootFiles: string[], options: CompilerOptions, configFile: string) {
924924
const system = createTestSystem(files);
925925
verifyProgramWithoutConfigFile(system, rootFiles, options);
926926
verifyProgramWithConfigFile(system, configFile);
927927
}
928928

929929
it("has empty options", () => {
930-
const file1: FileOrFolder = {
930+
const file1: File = {
931931
path: "/a/b/file1.ts",
932932
content: "let x = 1"
933933
};
934-
const file2: FileOrFolder = {
934+
const file2: File = {
935935
path: "/a/b/file2.ts",
936936
content: "let y = 1"
937937
};
938-
const configFile: FileOrFolder = {
938+
const configFile: File = {
939939
path: "/a/b/tsconfig.json",
940940
content: "{}"
941941
};
@@ -944,19 +944,19 @@ namespace ts {
944944

945945
it("has lib specified in the options", () => {
946946
const compilerOptions: CompilerOptions = { lib: ["es5", "es2015.promise"] };
947-
const app: FileOrFolder = {
947+
const app: File = {
948948
path: "/src/app.ts",
949949
content: "var x: Promise<string>;"
950950
};
951-
const configFile: FileOrFolder = {
951+
const configFile: File = {
952952
path: "/src/tsconfig.json",
953953
content: JSON.stringify({ compilerOptions })
954954
};
955-
const es5Lib: FileOrFolder = {
955+
const es5Lib: File = {
956956
path: "/compiler/lib.es5.d.ts",
957957
content: "declare const eval: any"
958958
};
959-
const es2015Promise: FileOrFolder = {
959+
const es2015Promise: File = {
960960
path: "/compiler/lib.es2015.promise.d.ts",
961961
content: "declare class Promise<T> {}"
962962
};
@@ -975,26 +975,26 @@ namespace ts {
975975
]
976976
}
977977
};
978-
const app: FileOrFolder = {
978+
const app: File = {
979979
path: "/src/packages/framework/app.ts",
980980
content: 'import classc from "module1/lib/file1";\
981981
import classD from "module3/file3";\
982982
let x = new classc();\
983983
let y = new classD();'
984984
};
985-
const module1: FileOrFolder = {
985+
const module1: File = {
986986
path: "/src/packages/mail/data/module1/lib/file1.ts",
987987
content: 'import classc from "module2/file2";export default classc;',
988988
};
989-
const module2: FileOrFolder = {
989+
const module2: File = {
990990
path: "/src/packages/mail/data/module1/lib/module2/file2.ts",
991991
content: 'class classc { method2() { return "hello"; } }\nexport default classc',
992992
};
993-
const module3: FileOrFolder = {
993+
const module3: File = {
994994
path: "/src/packages/styles/module3/file3.ts",
995995
content: "class classD { method() { return 10; } }\nexport default classD;"
996996
};
997-
const configFile: FileOrFolder = {
997+
const configFile: File = {
998998
path: "/src/tsconfig.json",
999999
content: JSON.stringify({ compilerOptions })
10001000
};
@@ -1013,26 +1013,26 @@ namespace ts {
10131013
]
10141014
}
10151015
};
1016-
const app: FileOrFolder = {
1016+
const app: File = {
10171017
path: "/src/packages/framework/app.ts",
10181018
content: 'import classc from "module1/lib/file1";\
10191019
import classD from "module3/file3";\
10201020
let x = new classc();\
10211021
let y = new classD();'
10221022
};
1023-
const module1: FileOrFolder = {
1023+
const module1: File = {
10241024
path: "/src/packages/mail/data/module1/lib/file1.ts",
10251025
content: 'import classc from "module2/file2";export default classc;',
10261026
};
1027-
const module2: FileOrFolder = {
1027+
const module2: File = {
10281028
path: "/src/packages/mail/data/module1/lib/module2/file2.ts",
10291029
content: 'class classc { method2() { return "hello"; } }\nexport default classc',
10301030
};
1031-
const module3: FileOrFolder = {
1031+
const module3: File = {
10321032
path: "/src/packages/styles/module3/file3.ts",
10331033
content: "class classD { method() { return 10; } }\nexport default classD;"
10341034
};
1035-
const configFile: FileOrFolder = {
1035+
const configFile: File = {
10361036
path: "/src/tsconfig.json",
10371037
content: JSON.stringify({ compilerOptions, include: ["packages/**/*.ts"] })
10381038
};

src/harness/unittests/telemetry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ namespace ts.projectSystem {
236236
});
237237
});
238238

239-
function makeFile(path: string, content: {} = ""): FileOrFolder {
239+
function makeFile(path: string, content: {} = ""): File {
240240
return { path, content: isString(content) ? "" : JSON.stringify(content) };
241241
}
242242
}

0 commit comments

Comments
 (0)