Skip to content

Commit 60f2534

Browse files
committed
Fix remaining unit tests on Linux
1 parent dd987f2 commit 60f2534

File tree

8 files changed

+35
-20
lines changed

8 files changed

+35
-20
lines changed

site/overview.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,18 @@ import * as td from "typedoc";
5252
// Also accepts an array of option readers if you want to disable
5353
// TypeDoc's tsconfig.json/package.json/typedoc.json option readers
5454
const app = await td.Application.bootstrapWithPlugins({
55+
// Note: This accepts globs, do not pass paths with backslash path separators!
5556
entryPoints: ["src/index.ts"],
5657
});
5758

5859
// May be undefined if errors are encountered.
5960
const project = await app.convert();
6061

6162
if (project) {
63+
// Generate configured outputs
64+
await generateOutputs(project);
65+
66+
// Alternatively...
6267
const outputDir = "docs";
6368
// Generate HTML rendered docs
6469
await app.generateDocs(project, outputDir);

src/lib/utils/options/options.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type ts from "typescript";
22
import { resolve } from "path";
33
import { ParameterType } from "./declaration.js";
4-
import type { OutputSpecification } from "../index.js";
4+
import { normalizePath, type OutputSpecification } from "../index.js";
55
import type { Application } from "../../../index.js";
66
import type { Logger } from "../loggers.js";
77
import {
@@ -353,7 +353,7 @@ export class Options {
353353
).map((c) => {
354354
return {
355355
...c,
356-
path: resolve(configPath ?? process.cwd(), c.path),
356+
path: normalizePath(resolve(configPath ?? process.cwd(), c.path)),
357357
};
358358
});
359359
} else {

src/lib/utils/paths.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export function createGlobString(relativeTo: NormalizedPath, glob: string): Glob
6565
if (isAbsolute(glob) || isGlobalGlob(glob)) return glob as GlobString;
6666

6767
const split = splitGlobToPathAndSpecial(glob);
68-
const leadingPath = normalizePath(resolve(relativeTo, split.path)).replace(/^\w:\//, "");
68+
const leadingPath = normalizePath(resolve(relativeTo, split.path));
6969

7070
if (!split.glob) {
7171
return split.modifiers + escapeGlob(leadingPath) as GlobString;

src/test/merge.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { deepStrictEqual as equal, ok } from "assert";
22
import { join } from "path";
3-
import { Application, type DeclarationReflection, EntryPointStrategy, ReferenceType } from "../index.js";
3+
import { Application, type DeclarationReflection, EntryPointStrategy, normalizePath, ReferenceType } from "../index.js";
44
import { getConverterBase } from "./programs.js";
55
import { TestLogger } from "./TestLogger.js";
66

@@ -11,8 +11,8 @@ describe("Merging projects", () => {
1111
const app = await Application.bootstrap({
1212
entryPointStrategy: EntryPointStrategy.Merge,
1313
entryPoints: [
14-
join(base, "alias/specs.json"),
15-
join(base, "class/*specs.json"),
14+
normalizePath(join(base, "alias/specs.json")),
15+
normalizePath(join(base, "class/*specs.json")),
1616
],
1717
projectDocuments: [],
1818
name: "typedoc",

src/test/output/output.test.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Outputs } from "../../lib/output/output.js";
55
import { TestLogger } from "../TestLogger.js";
66
import { FileRegistry, ProjectReflection } from "../../lib/models/index.js";
77
import type { TranslatedString } from "../../lib/internationalization/index.js";
8+
import { normalizePath } from "#node-utils";
89

910
const app = getConverter2App();
1011

@@ -46,22 +47,22 @@ describe("Output", () => {
4647

4748
it("Uses the --out output by default", () => {
4849
const specs = outputs.getOutputSpecs();
49-
equal(specs, [{ name: "html", path: resolve("./docs") }]);
50+
equal(specs, [{ name: "html", path: normalizePath(resolve("./docs")) }]);
5051
});
5152

5253
it("Does not use default value of --out if there is a specified output shortcut", () => {
5354
app.options.setValue("html", "./html_docs");
5455
const specs = outputs.getOutputSpecs();
55-
equal(specs, [{ name: "html", path: resolve("./html_docs") }]);
56+
equal(specs, [{ name: "html", path: normalizePath(resolve("./html_docs")) }]);
5657
});
5758

5859
it("Uses --out if specified", () => {
5960
app.options.setValue("html", "./html_docs");
6061
app.options.setValue("out", "./out_docs");
6162
const specs = outputs.getOutputSpecs();
6263
equal(specs, [
63-
{ name: "html", path: resolve("./out_docs") },
64-
{ name: "html", path: resolve("./html_docs") },
64+
{ name: "html", path: normalizePath(resolve("./out_docs")) },
65+
{ name: "html", path: normalizePath(resolve("./html_docs")) },
6566
]);
6667
});
6768

@@ -70,7 +71,7 @@ describe("Output", () => {
7071
{ name: "html", path: "./html_docs" },
7172
]);
7273
const specs = outputs.getOutputSpecs();
73-
equal(specs, [{ name: "html", path: resolve("./html_docs") }]);
74+
equal(specs, [{ name: "html", path: normalizePath(resolve("./html_docs")) }]);
7475
});
7576

7677
it("Prioritizes shortcuts if both outputs and shortcuts are specified", () => {
@@ -79,7 +80,7 @@ describe("Output", () => {
7980
]);
8081
app.options.setValue("html", "./html_docs2");
8182
const specs = outputs.getOutputSpecs();
82-
equal(specs, [{ name: "html", path: resolve("./html_docs2") }]);
83+
equal(specs, [{ name: "html", path: normalizePath(resolve("./html_docs2")) }]);
8384
});
8485

8586
it("Prioritizes --out if both outputs and --out are specified", () => {
@@ -88,14 +89,14 @@ describe("Output", () => {
8889
]);
8990
app.options.setValue("out", "./html_docs2");
9091
const specs = outputs.getOutputSpecs();
91-
equal(specs, [{ name: "html", path: resolve("./html_docs2") }]);
92+
equal(specs, [{ name: "html", path: normalizePath(resolve("./html_docs2")) }]);
9293
});
9394

9495
it("Supports specifying a different default output name", () => {
9596
outputs.setDefaultOutputName("json");
9697
const specs = outputs.getOutputSpecs();
9798
try {
98-
equal(specs, [{ name: "json", path: resolve("./docs") }]);
99+
equal(specs, [{ name: "json", path: normalizePath(resolve("./docs")) }]);
99100
} finally {
100101
outputs.setDefaultOutputName("html");
101102
}

src/test/slow/entry-point.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ describe("Entry Points", () => {
2727
it("Supports expanding existing paths", async () => {
2828
const app = await Application.bootstrap({
2929
tsconfig,
30-
entryPoints: [fixture.cwd],
30+
entryPoints: [normalizePath(fixture.cwd)],
3131
entryPointStrategy: EntryPointStrategy.Expand,
3232
});
3333

34+
equal(app.options.getValue("entryPoints"), [normalizePath(fixture.cwd)]);
35+
3436
const entryPoints = app.getDefinedEntryPoints();
3537
ok(entryPoints);
3638
equal(

src/test/utils/options/readers/arguments.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ describe("Options - ArgumentsReader", () => {
6868
});
6969

7070
test("Works with string options", ["--out", "outDir"], () => {
71-
equal(options.getValue("out"), join(process.cwd(), "outDir"));
71+
equal(options.getValue("out"), normalizePath(join(process.cwd(), "outDir")));
7272
});
7373

7474
test("Works with number options", ["-numOption", "123"], () => {

src/test/utils/paths.test.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,17 @@ describe("paths.ts", () => {
6969
});
7070

7171
it("Handles file paths", () => {
72-
equal(
73-
createGlobString("/test/typedoc" as NormalizedPath, "src/index.ts"),
74-
"/test/typedoc/src/index.ts",
75-
);
72+
if (process.platform == "win32") {
73+
equal(
74+
createGlobString("C:/test/typedoc" as NormalizedPath, "src/index.ts"),
75+
"C:/test/typedoc/src/index.ts",
76+
);
77+
} else {
78+
equal(
79+
createGlobString("/test/typedoc" as NormalizedPath, "src/index.ts"),
80+
"/test/typedoc/src/index.ts",
81+
);
82+
}
7683
});
7784
});
7885

0 commit comments

Comments
 (0)