From e9cddd471d4c8ff40261ec1808c446272e6f6246 Mon Sep 17 00:00:00 2001 From: Benjamin Lichtman Date: Fri, 1 Jun 2018 14:21:21 -0700 Subject: [PATCH] Add test --- src/harness/unittests/typingsInstaller.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/harness/unittests/typingsInstaller.ts b/src/harness/unittests/typingsInstaller.ts index 34176e8563c..0b355d5aa89 100644 --- a/src/harness/unittests/typingsInstaller.ts +++ b/src/harness/unittests/typingsInstaller.ts @@ -1340,6 +1340,27 @@ namespace ts.projectSystem { assert.deepEqual(result.newTypingNames, ["bar"]); }); + it("should gracefully handle packages that have been removed from the types-registry", () => { + const f = { + path: "/a/b/app.js", + content: "" + }; + const node = { + path: "/a/b/node.d.ts", + content: "" + }; + const host = createServerHost([f, node]); + const cache = createMapFromTemplate({ node: { typingLocation: node.path, version: Semver.parse("1.3.0") } }); + const logger = trackingLogger(); + const result = JsTyping.discoverTypings(host, logger.log, [f.path], getDirectoryPath(f.path), emptySafeList, cache, { enable: true }, ["fs", "bar"], emptyMap); + assert.deepEqual(logger.finish(), [ + 'Inferred typings from unresolved imports: ["node","bar"]', + 'Result: {"cachedTypingPaths":[],"newTypingNames":["node","bar"],"filesToWatch":["/a/b/bower_components","/a/b/node_modules"]}', + ]); + assert.deepEqual(result.cachedTypingPaths, []); + assert.deepEqual(result.newTypingNames, ["node", "bar"]); + }); + it("should search only 2 levels deep", () => { const app = { path: "/app.js",