Skip to content

Commit 253cde4

Browse files
committed
Fix tests
1 parent f2a801e commit 253cde4

File tree

6 files changed

+23
-17
lines changed

6 files changed

+23
-17
lines changed

Gulpfile.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ gulp.task(tsserverLibraryFile, /*help*/ false, [servicesFile, typesMapJson], (do
474474
.pipe(sourcemaps.init())
475475
.pipe(newer(tsserverLibraryFile))
476476
.pipe(serverLibraryProject());
477-
477+
478478
return merge2([
479479
js.pipe(prependCopyright())
480480
.pipe(sourcemaps.write("."))
@@ -488,7 +488,7 @@ gulp.task(tsserverLibraryFile, /*help*/ false, [servicesFile, typesMapJson], (do
488488
});
489489

490490
gulp.task(typesMapJson, /*help*/ false, [], () => {
491-
return gulp.src('src/server/typesMap.json')
491+
return gulp.src("src/server/typesMap.json")
492492
.pipe(insert.transform((contents, file) => {
493493
JSON.parse(contents);
494494
return contents;

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,8 @@
9595
"fs": false,
9696
"os": false,
9797
"path": false
98+
},
99+
"dependencies": {
100+
"browser-resolve": "^1.11.2"
98101
}
99102
}

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace ts.projectSystem {
1818
})
1919
};
2020

21-
const customTypesMap = {
21+
export const customTypesMap = {
2222
path: <Path>"/typesMap.json",
2323
content: `{
2424
"typesMap": {
@@ -33,7 +33,11 @@ namespace ts.projectSystem {
3333
},
3434
"simpleMap": {
3535
"Bacon": "baconjs",
36-
"bliss": "blissfuljs"
36+
"bliss": "blissfuljs",
37+
"commander": "commander",
38+
"cordova": "cordova",
39+
"react": "react",
40+
"lodash": "lodash"
3741
}
3842
}`
3943
};
@@ -297,10 +301,7 @@ namespace ts.projectSystem {
297301
}
298302

299303
export function checkFileNames(caption: string, actualFileNames: string[], expectedFileNames: string[]) {
300-
assert.equal(actualFileNames.length, expectedFileNames.length, `${caption}: incorrect actual number of files, expected ${JSON.stringify(expectedFileNames)}, got ${actualFileNames}`);
301-
for (const f of expectedFileNames) {
302-
assert.isTrue(contains(actualFileNames, f), `${caption}: expected to find ${f} in ${JSON.stringify(actualFileNames)}`);
303-
}
304+
assert.sameMembers(actualFileNames, expectedFileNames, caption);
304305
}
305306

306307
export function checkNumberOfConfiguredProjects(projectService: server.ProjectService, expected: number) {
@@ -1500,7 +1501,7 @@ namespace ts.projectSystem {
15001501
projectService.resetSafeList();
15011502
}
15021503
});
1503-
1504+
15041505
it("ignores files excluded by the default type list", () => {
15051506
const file1 = {
15061507
path: "/a/b/f1.ts",

src/harness/unittests/typingsInstaller.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ namespace ts.projectSystem {
322322
content: "declare const lodash: { x: number }"
323323
};
324324

325-
const host = createServerHost([file1, file2, file3]);
325+
const host = createServerHost([file1, file2, file3, customTypesMap]);
326326
const installer = new (class extends Installer {
327327
constructor() {
328328
super(host, { typesRegistry: createTypesRegistry("lodash", "react") });
@@ -347,6 +347,7 @@ namespace ts.projectSystem {
347347
projectService.checkNumberOfProjects({ externalProjects: 1 });
348348
checkProjectActualFiles(p, [file1.path, file2.path, file3.path]);
349349

350+
debugger;
350351
installer.installAll(/*expectedCount*/ 1);
351352

352353
checkNumberOfProjects(projectService, { externalProjects: 1 });
@@ -445,7 +446,7 @@ namespace ts.projectSystem {
445446
content: "declare const moment: { x: number }"
446447
};
447448

448-
const host = createServerHost([file1, file2, file3, packageJson]);
449+
const host = createServerHost([file1, file2, file3, packageJson, customTypesMap]);
449450
const installer = new (class extends Installer {
450451
constructor() {
451452
super(host, { typesRegistry: createTypesRegistry("jquery", "commander", "moment", "express") });
@@ -521,7 +522,7 @@ namespace ts.projectSystem {
521522
};
522523

523524
const typingFiles = [commander, express, jquery, moment, lodash];
524-
const host = createServerHost([lodashJs, commanderJs, file3, packageJson]);
525+
const host = createServerHost([lodashJs, commanderJs, file3, packageJson, customTypesMap]);
525526
const installer = new (class extends Installer {
526527
constructor() {
527528
super(host, { throttleLimit: 3, typesRegistry: createTypesRegistry("commander", "express", "jquery", "moment", "lodash") });
@@ -600,7 +601,7 @@ namespace ts.projectSystem {
600601
typings: typingsName("gulp")
601602
};
602603

603-
const host = createServerHost([lodashJs, commanderJs, file3]);
604+
const host = createServerHost([lodashJs, commanderJs, file3, customTypesMap]);
604605
const installer = new (class extends Installer {
605606
constructor() {
606607
super(host, { throttleLimit: 1, typesRegistry: createTypesRegistry("commander", "jquery", "lodash", "cordova", "gulp", "grunt") });

src/server/editorServices.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ namespace ts.server {
411411
this.globalPlugins = opts.globalPlugins || emptyArray;
412412
this.pluginProbeLocations = opts.pluginProbeLocations || emptyArray;
413413
this.allowLocalPluginLoads = !!opts.allowLocalPluginLoads;
414-
this.typesMapLocation = (opts.typesMapLocation === undefined) ? combinePaths(this.host.getExecutingFilePath(), '../typesMap.json') : opts.typesMapLocation;
414+
this.typesMapLocation = (opts.typesMapLocation === undefined) ? combinePaths(this.host.getExecutingFilePath(), "../typesMap.json") : opts.typesMapLocation;
415415

416416
Debug.assert(!!this.host.createHash, "'ServerHost.createHash' is required for ProjectService");
417417

@@ -472,7 +472,8 @@ namespace ts.server {
472472
}
473473
// raw is now fixed and ready
474474
this.safelist = raw.typesMap;
475-
} catch(e) {
475+
}
476+
catch (e) {
476477
this.logger.info(`Error loading types map: ${e}`);
477478
this.safelist = defaultTypeSafeList;
478479
}
@@ -1721,7 +1722,7 @@ namespace ts.server {
17211722

17221723
const excludeRegexes = excludeRules.map(e => new RegExp(e, "i"));
17231724
const filesToKeep: ts.server.protocol.ExternalFile[] = [];
1724-
for(let i = 0; i < proj.rootFiles.length; i++) {
1725+
for (let i = 0; i < proj.rootFiles.length; i++) {
17251726
if (excludeRegexes.some(re => re.test(normalizedNames[i]))) {
17261727
excludedFiles.push(normalizedNames[i]);
17271728
}

src/server/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ namespace ts.server {
763763
}
764764

765765
const typingSafeListLocation = findArgument(Arguments.TypingSafeListLocation);
766-
const typesMapLocation = findArgument(Arguments.TypesMapLocation) || combinePaths(sys.getExecutingFilePath(), '../typesMap.json');
766+
const typesMapLocation = findArgument(Arguments.TypesMapLocation) || combinePaths(sys.getExecutingFilePath(), "../typesMap.json");
767767
const npmLocation = findArgument(Arguments.NpmLocation);
768768

769769
const globalPlugins = (findArgument("--globalPlugins") || "").split(",");

0 commit comments

Comments
 (0)