From d4e4b432391dc5028b578375fb07c275d960136c Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 2 Oct 2018 13:36:06 -0700 Subject: [PATCH] Verify that own config change in module resolution gets reflected --- src/testRunner/unittests/tsbuildWatchMode.ts | 40 ++++++++++++++------ 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/src/testRunner/unittests/tsbuildWatchMode.ts b/src/testRunner/unittests/tsbuildWatchMode.ts index 4226ae2e02a..242c55f8200 100644 --- a/src/testRunner/unittests/tsbuildWatchMode.ts +++ b/src/testRunner/unittests/tsbuildWatchMode.ts @@ -542,19 +542,13 @@ export function gfoo() { return expectedFiles.map(file => [file, host.getModifiedTime(file)] as OutputFileStamp); } - function verifyWatches(host: WatchedSystem) { - verifyWatchesOfProject(host, expectedWatchedFiles, expectedWatchedDirectoriesRecursive); - } - function verifyProgram(host: WatchedSystem, watch: () => BuilderProgram) { - verifyWatches(host); - - verifyDependencies(watch, aDts, [aDts]); - verifyDependencies(watch, refs.path, [refs.path]); - verifyDependencies(watch, bDts, [bDts, aDts]); - verifyDependencies(watch, cTs.path, [cTs.path, refs.path, bDts]); - + verifyWatchesOfProject(host, expectedWatchedFiles, expectedWatchedDirectoriesRecursive); checkProgramActualFiles(watch().getProgram(), expectedProgramFiles); + verifyDependencies(watch, aDts, [aDts]); + verifyDependencies(watch, bDts, [bDts, aDts]); + verifyDependencies(watch, refs.path, [refs.path]); + verifyDependencies(watch, cTs.path, [cTs.path, refs.path, bDts]); } it("verifies dependencies and watches", () => { @@ -577,6 +571,30 @@ export function gfoo() { checkOutputErrorsIncremental(host, emptyArray); verifyProgram(host, watch); }); + + it("edit on config file", () => { + const { host, watch } = createSolutionAndWatchMode(); + + const nrefs: File = { + path: getFilePathInProject(project, "nrefs/a.d.ts"), + content: refs.content + }; + const cTsConfigJson = JSON.parse(cTsconfig.content); + host.ensureFileOrFolder(nrefs); + cTsConfigJson.compilerOptions.paths = { "@ref/*": ["./nrefs/*"] }; + host.writeFile(cTsconfig.path, JSON.stringify(cTsConfigJson)); + + host.checkTimeoutQueueLengthAndRun(1); + checkOutputErrorsIncremental(host, emptyArray); + + const nrefReplacer = (f: string) => f.replace("refs", "nrefs"); + verifyWatchesOfProject(host, expectedWatchedFiles.map(nrefReplacer), expectedWatchedDirectoriesRecursive.map(nrefReplacer)); + checkProgramActualFiles(watch().getProgram(), expectedProgramFiles.map(nrefReplacer)); + verifyDependencies(watch, aDts, [aDts]); + verifyDependencies(watch, bDts, [bDts, aDts]); + verifyDependencies(watch, nrefs.path, [nrefs.path]); + verifyDependencies(watch, cTs.path, [cTs.path, nrefs.path, bDts]); + }); }); }); });