Skip to content

Commit 2312bd9

Browse files
committed
Update typingsInstaller tests
1 parent 499cd4c commit 2312bd9

25 files changed

Lines changed: 6081 additions & 950 deletions

src/testRunner/unittests/tsserver/typingsInstaller.ts

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ describe("unittests:: tsserver:: typingsInstaller:: General functionality", () =
7878
content: jsonToReadableText({
7979
compilerOptions: {
8080
allowJs: true,
81+
types: ["*"],
8182
},
8283
typeAcquisition: {
8384
enable: true,
@@ -146,6 +147,10 @@ describe("unittests:: tsserver:: typingsInstaller:: General functionality", () =
146147
useSingleInferredProject: true,
147148
installAction: [jquery],
148149
});
150+
setCompilerOptionsForInferredProjectsRequestForSession({
151+
allowJs: true,
152+
types: ["*"],
153+
}, session);
149154
openFilesForSession([file1], session);
150155

151156
host.runPendingInstalls();
@@ -806,7 +811,7 @@ describe("unittests:: tsserver:: typingsInstaller:: General functionality", () =
806811
};
807812
const jsconfig = {
808813
path: "/user/username/projects/project/jsconfig.json",
809-
content: jsonToReadableText({}),
814+
content: jsonToReadableText({ compilerOptions: { types: ["*"] } }),
810815
};
811816
// Should only accept direct dependencies.
812817
const commander = {
@@ -917,7 +922,9 @@ describe("unittests:: tsserver:: typingsInstaller:: General functionality", () =
917922
});
918923
}
919924

920-
testConfiguredProjectNodeModules("discover from node_modules", {});
925+
testConfiguredProjectNodeModules("discover from node_modules", {
926+
jsconfigContent: { compilerOptions: { types: ["*"] } },
927+
});
921928

922929
// Explicit types prevent automatic inclusion from package.json listing
923930
testConfiguredProjectNodeModules("discover from node_modules empty types", {
@@ -942,7 +949,7 @@ describe("unittests:: tsserver:: typingsInstaller:: General functionality", () =
942949
};
943950
const jsconfig = {
944951
path: "/user/username/projects/project/jsconfig.json",
945-
content: jsonToReadableText({}),
952+
content: jsonToReadableText({ compilerOptions: { types: ["*"] } }),
946953
};
947954
const jquery = {
948955
path: "/user/username/projects/project/bower_components/jquery/index.js",
@@ -980,7 +987,7 @@ describe("unittests:: tsserver:: typingsInstaller:: General functionality", () =
980987
};
981988
const jsconfig = {
982989
path: "/user/username/projects/project/jsconfig.json",
983-
content: jsonToReadableText({}),
990+
content: jsonToReadableText({ compilerOptions: { types: ["*"] } }),
984991
};
985992
const bowerJson = {
986993
path: "/user/username/projects/project/bower.json",
@@ -1036,6 +1043,10 @@ describe("unittests:: tsserver:: typingsInstaller:: General functionality", () =
10361043
host,
10371044
installAction: [commander],
10381045
});
1046+
setCompilerOptionsForInferredProjectsRequestForSession({
1047+
allowJs: true,
1048+
types: ["*"],
1049+
}, session);
10391050
openFilesForSession([f], session);
10401051

10411052
host.writeFile(fixedPackageJson.path, fixedPackageJson.content);
@@ -1197,6 +1208,7 @@ describe("unittests:: tsserver:: typingsInstaller:: General functionality", () =
11971208
content: jsonToReadableText({
11981209
compilerOptions: {
11991210
allowJs: true,
1211+
types: ["*"],
12001212
},
12011213
typeAcquisition: {
12021214
enable: true,
@@ -1221,6 +1233,7 @@ describe("unittests:: tsserver:: typingsInstaller:: General functionality", () =
12211233
content: jsonToReadableText({
12221234
compilerOptions: {
12231235
allowJs: true,
1236+
types: ["*"],
12241237
},
12251238
typeAcquisition: {
12261239
enable: true,
@@ -1314,6 +1327,10 @@ describe("unittests:: tsserver:: typingsInstaller:: General functionality", () =
13141327
useSingleInferredProject: true,
13151328
installAction: [jquery],
13161329
});
1330+
setCompilerOptionsForInferredProjectsRequestForSession({
1331+
allowJs: true,
1332+
types: ["*"],
1333+
}, session);
13171334
openFilesForSession([file1], session);
13181335
host.runPendingInstalls();
13191336
host.runQueuedTimeoutCallbacks();
@@ -1368,6 +1385,10 @@ describe("unittests:: tsserver:: typingsInstaller:: General functionality", () =
13681385
useSingleInferredProject: true,
13691386
installAction: true,
13701387
});
1388+
setCompilerOptionsForInferredProjectsRequestForSession({
1389+
allowJs: true,
1390+
types: ["*"],
1391+
}, session);
13711392
openFilesForSession([file1], session);
13721393
host.runPendingInstalls();
13731394
baselineTsserverLogs("typingsInstaller", "non expired cache entry", session);
@@ -1421,6 +1442,10 @@ describe("unittests:: tsserver:: typingsInstaller:: General functionality", () =
14211442
useSingleInferredProject: true,
14221443
installAction: [jquery],
14231444
});
1445+
setCompilerOptionsForInferredProjectsRequestForSession({
1446+
allowJs: true,
1447+
types: ["*"],
1448+
}, session);
14241449
openFilesForSession([file1], session);
14251450
host.runPendingInstalls();
14261451
host.runQueuedTimeoutCallbacks();
@@ -1475,6 +1500,10 @@ describe("unittests:: tsserver:: typingsInstaller:: General functionality", () =
14751500
useSingleInferredProject: true,
14761501
installAction: true,
14771502
});
1503+
setCompilerOptionsForInferredProjectsRequestForSession({
1504+
allowJs: true,
1505+
types: ["*"],
1506+
}, session);
14781507
openFilesForSession([file1], session);
14791508
host.runPendingInstalls();
14801509
baselineTsserverLogs("typingsInstaller", "non expired cache entry lockFile3", session);
@@ -1579,7 +1608,7 @@ describe("unittests:: tsserver:: typingsInstaller:: discover typings", () => {
15791608
{ enable: true },
15801609
ts.emptyArray,
15811610
ts.emptyMap,
1582-
ts.emptyOptions,
1611+
{ types: ["*"] },
15831612
);
15841613
baseline("should use mappings from safe list");
15851614
});
@@ -1601,7 +1630,7 @@ describe("unittests:: tsserver:: typingsInstaller:: discover typings", () => {
16011630
{ enable: true },
16021631
[name, "somename"],
16031632
ts.emptyMap,
1604-
ts.emptyOptions,
1633+
{ types: ["*"] },
16051634
);
16061635
}
16071636
baseline("should return node for core modules");
@@ -1619,7 +1648,7 @@ describe("unittests:: tsserver:: typingsInstaller:: discover typings", () => {
16191648
const { discoverTypings, baseline } = setup([f, node]);
16201649
const cache = new Map(Object.entries<ts.JsTyping.CachedTyping>({ node: { typingLocation: node.path, version: new ts.Version("1.3.0") } }));
16211650
const registry = createTypesRegistry("node");
1622-
discoverTypings([f.path], ts.getDirectoryPath(f.path as ts.Path), emptySafeList, cache, { enable: true }, ["fs", "bar"], registry, ts.emptyOptions);
1651+
discoverTypings([f.path], ts.getDirectoryPath(f.path as ts.Path), emptySafeList, cache, { enable: true }, ["fs", "bar"], registry, { types: ["*"] });
16231652
baseline("should use cached locations");
16241653
});
16251654

@@ -1642,7 +1671,7 @@ describe("unittests:: tsserver:: typingsInstaller:: discover typings", () => {
16421671
{ enable: true },
16431672
["fs", "bar"],
16441673
ts.emptyMap,
1645-
ts.emptyOptions,
1674+
{ types: ["*"] },
16461675
);
16471676
baseline("should gracefully handle packages that have been removed from the types-registry");
16481677
});
@@ -1670,7 +1699,7 @@ describe("unittests:: tsserver:: typingsInstaller:: discover typings", () => {
16701699
{ enable: true },
16711700
/*unresolvedImports*/ [],
16721701
ts.emptyMap,
1673-
ts.emptyOptions,
1702+
{ types: ["*"] },
16741703
);
16751704
baseline("should search only 2 levels deep");
16761705
});
@@ -1694,7 +1723,7 @@ describe("unittests:: tsserver:: typingsInstaller:: discover typings", () => {
16941723
{ enable: true },
16951724
/*unresolvedImports*/ [],
16961725
ts.emptyMap,
1697-
ts.emptyOptions,
1726+
{ types: ["*"] },
16981727
);
16991728
baseline("should support scoped packages");
17001729
});
@@ -1725,7 +1754,7 @@ describe("unittests:: tsserver:: typingsInstaller:: discover typings", () => {
17251754
{ enable: true },
17261755
["http", "commander"],
17271756
registry,
1728-
ts.emptyOptions,
1757+
{ types: ["*"] },
17291758
);
17301759
baseline("should install expired typings");
17311760
});
@@ -1753,7 +1782,7 @@ describe("unittests:: tsserver:: typingsInstaller:: discover typings", () => {
17531782
{ enable: true },
17541783
["http"],
17551784
registry,
1756-
ts.emptyOptions,
1785+
{ types: ["*"] },
17571786
);
17581787
baseline("should install expired typings with prerelease version of tsserver");
17591788
});
@@ -1786,7 +1815,7 @@ describe("unittests:: tsserver:: typingsInstaller:: discover typings", () => {
17861815
{ enable: true },
17871816
["http", "commander"],
17881817
registry,
1789-
ts.emptyOptions,
1818+
{ types: ["*"] },
17901819
);
17911820
baseline("prerelease typings are properly handled");
17921821
});
@@ -1879,6 +1908,10 @@ describe("unittests:: tsserver:: typingsInstaller:: telemetry events", () => {
18791908
host,
18801909
installAction: [commander],
18811910
});
1911+
setCompilerOptionsForInferredProjectsRequestForSession({
1912+
allowJs: true,
1913+
types: ["*"],
1914+
}, session);
18821915
openFilesForSession([f1], session);
18831916

18841917
host.runPendingInstalls();
@@ -1920,6 +1953,10 @@ describe("unittests:: tsserver:: typingsInstaller:: progress notifications", ()
19201953
host,
19211954
installAction: [commander],
19221955
});
1956+
setCompilerOptionsForInferredProjectsRequestForSession({
1957+
allowJs: true,
1958+
types: ["*"],
1959+
}, session);
19231960
openFilesForSession([f1], session);
19241961

19251962
host.runPendingInstalls();
@@ -1944,6 +1981,10 @@ describe("unittests:: tsserver:: typingsInstaller:: progress notifications", ()
19441981
host,
19451982
installAction: false,
19461983
});
1984+
setCompilerOptionsForInferredProjectsRequestForSession({
1985+
allowJs: true,
1986+
types: ["*"],
1987+
}, session);
19471988
openFilesForSession([f1], session);
19481989

19491990
host.runPendingInstalls();

0 commit comments

Comments
 (0)