Skip to content

Commit bdaaf66

Browse files
committed
added type installer test for inferred project
1 parent f642a47 commit bdaaf66

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,5 +1534,45 @@ namespace ts {
15341534
checkNumberOfProjects(projectService, { configuredProjects: 1 });
15351535
checkProjectActualFiles(p, [ file1.path, jquery.path ]);
15361536
});
1537+
1538+
it ("inferred project (tsd installed)", () => {
1539+
const file1 = {
1540+
path: "/a/b/app.js",
1541+
content: ""
1542+
};
1543+
const packageJson = {
1544+
path: "/a/b/package.json",
1545+
content: JSON.stringify({
1546+
name: "test",
1547+
dependencies: {
1548+
jquery: "^3.1.0"
1549+
}
1550+
})
1551+
};
1552+
1553+
const jquery = {
1554+
path: "/a/data/typings/jquery/jquery.d.ts",
1555+
content: "declare const $: { x: number }"
1556+
};
1557+
const host = createServerHost([file1, packageJson]);
1558+
const installer = new TestTypingsInstaller("/a/data/", host);
1559+
1560+
const projectService = new server.ProjectService(host, nullLogger, nullCancellationToken, /*useSingleInferredProject*/ true, installer);
1561+
projectService.openClientFile(file1.path);
1562+
1563+
checkNumberOfProjects(projectService, { inferredProjects: 1 });
1564+
const p = projectService.inferredProjects[0];
1565+
checkProjectActualFiles(p, [ file1.path ]);
1566+
1567+
assert(host.fileExists(combinePaths(installer.cachePath, "tsd.json")));
1568+
1569+
installer.runPostInstallActions(t => {
1570+
assert.deepEqual(t, ["jquery"]);
1571+
host.createFileOrFolder(jquery, /*createParentDirectory*/ true);
1572+
return ["jquery/jquery.d.ts"];
1573+
});
1574+
checkNumberOfProjects(projectService, { inferredProjects: 1 });
1575+
checkProjectActualFiles(p, [ file1.path, jquery.path ]);
1576+
});
15371577
});
15381578
}

0 commit comments

Comments
 (0)