From 27d2a2d5646263658bbf17e25b70f087f820cdfe Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Wed, 8 Aug 2018 17:05:31 +0200 Subject: [PATCH] add test --- src/testRunner/unittests/moduleResolution.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/testRunner/unittests/moduleResolution.ts b/src/testRunner/unittests/moduleResolution.ts index e97a3f5fc42..5f8251afb0a 100644 --- a/src/testRunner/unittests/moduleResolution.ts +++ b/src/testRunner/unittests/moduleResolution.ts @@ -194,6 +194,21 @@ namespace ts { }); describe("Node module resolution - non-relative paths", () => { + it("computes correct commonPrefix for moduleName cache", () => { + const cache = createModuleResolutionCache("/", (f) => f).getOrCreateCacheForModuleName("a"); + cache.set("/sub", { + resolvedModule: { + originalPath: undefined, + resolvedFileName: "/sub/node_modules/a/index.ts", + isExternalLibraryImport: true, + extension: Extension.Ts, + }, + failedLookupLocations: [], + }); + assert.isDefined(cache.get("/sub")); + assert.isUndefined(cache.get("/")); + }); + it("load module as file - ts files not loaded", () => { test(/*hasDirectoryExists*/ false); test(/*hasDirectoryExists*/ true);