Skip to content

Commit 098b1c7

Browse files
committed
Improve test coverage
1 parent 35ccb69 commit 098b1c7

File tree

13 files changed

+1326
-46
lines changed

13 files changed

+1326
-46
lines changed

scripts/rebuild_specs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ async function rebuildRendererTest(specPath) {
136136
app2.options.setValue("disableGit", true);
137137
app2.options.setValue("sourceLinkTemplate", "{path}:{line}");
138138

139+
td.resetReflectionID();
139140
const project = getConverter2Project(["renderer"], ".");
140141
project.readme = [{ kind: "text", text: "Readme text" }];
141142
await app2.generateDocs(project, specPath);

src/lib/output/themes/default/DefaultTheme.tsx

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { getIcons, type Icons } from "./partials/icon.js";
1818
import { filterMap, JSX } from "#utils";
1919
import { classNames, getDisplayName, toStyleClass } from "../lib.js";
2020
import { PageKind, type Router } from "../../router.js";
21-
import { createNormalizedUrl, loadHighlighter, Option } from "#node-utils";
21+
import { loadHighlighter, Option } from "#node-utils";
2222
import type { BundledLanguage, BundledTheme as ShikiTheme } from "@gerrit0/mini-shiki";
2323

2424
export interface NavigationElement {
@@ -111,32 +111,6 @@ export class DefaultTheme extends Theme {
111111
this.router = renderer.router!;
112112
}
113113

114-
/**
115-
* @param reflection The reflection the url should be generated for.
116-
*/
117-
getFileName(reflection: Reflection): string {
118-
const parts = [createNormalizedUrl(reflection.name)];
119-
while (reflection.parent && !reflection.parent.isProject()) {
120-
reflection = reflection.parent;
121-
parts.unshift(createNormalizedUrl(reflection.name));
122-
}
123-
124-
const baseName = parts.join(".");
125-
const lowerBaseName = baseName.toLocaleLowerCase();
126-
if (this.usedFileNames.has(lowerBaseName)) {
127-
let index = 1;
128-
while (this.usedFileNames.has(`${lowerBaseName}-${index}`)) {
129-
++index;
130-
}
131-
132-
this.usedFileNames.add(`${lowerBaseName}-${index}`);
133-
return `${baseName}-${index}.html`;
134-
}
135-
136-
this.usedFileNames.add(lowerBaseName);
137-
return `${baseName}.html`;
138-
}
139-
140114
render(page: PageEvent<Reflection>): string {
141115
const template = {
142116
[PageKind.Index]: this.indexTemplate,

src/lib/output/themes/default/partials/navigation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ function buildSectionNavigation(context: DefaultThemeRenderContext, headings: Pa
179179
}
180180

181181
levels[levels.length - 1].push(
182-
<a href={heading.link} class={heading.classes}>
182+
<a href={heading.link} class={classNames({}, heading.classes)}>
183183
{heading.kind && context.icons[heading.kind]()}
184184
<span>{wbr(heading.text)}</span>
185185
</a>,

src/test/converter2/renderer/index.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@
77

88
// Exports from this file will be rendered for the renderer snapshot testing
99

10+
export class BaseClass {}
11+
1012
/** Renderer class */
11-
export class RenderClass {
13+
export class RenderClass extends BaseClass {
1214
/** Index signature */
1315
[k: string]: unknown;
1416

1517
/** Property */
1618
prop: string = "abc";
1719

1820
/** Ctor comment */
19-
constructor(x: string) {}
21+
constructor(x: string) {
22+
super();
23+
}
2024

2125
/** Method comment */
2226
method(x: string) {}
@@ -29,13 +33,31 @@ export class RenderClass {
2933
overloaded(p?: string): number | string {
3034
return 1;
3135
}
36+
37+
get getter() {
38+
return 1;
39+
}
40+
41+
get getSet() {
42+
return 1;
43+
}
44+
set getSet(value: number) {}
3245
}
3346

3447
/** Generic class */
3548
export class GenericClass<out T extends string = ""> {
3649
genericMethod<U extends T>() {}
3750
}
3851

52+
export class ModifiersClass {
53+
protected prot = 1;
54+
private priv = 2;
55+
public pub = 3;
56+
readonly read = 4;
57+
/** @deprecated */
58+
dep = 5;
59+
}
60+
3961
/**
4062
* Enum comment {@link Value1}
4163
* @remarks Block tag

src/test/renderer/DefaultTheme.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { deepEqual as equal } from "assert/strict";
55
import { glob, readFile } from "#node-utils";
66
import type { GlobString, NormalizedPath } from "#utils";
77
import { join, relative } from "path";
8+
import { resetReflectionID } from "#models";
89

910
const app = getConverter2App();
1011

@@ -26,6 +27,7 @@ describe("DefaultTheme", () => {
2627
app.options.setValue("disableGit", true);
2728
app.options.setValue("sourceLinkTemplate", "{path}:{line}");
2829

30+
resetReflectionID();
2931
const project = getConverter2Project(["renderer"], ".");
3032
project.readme = [{ kind: "text", text: "Readme text" }];
3133
await app.generateDocs(project, outPath);
Lines changed: 260 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,260 @@
1+
{
2+
"div.container.container-main": [
3+
{
4+
"div.col-content": [
5+
{
6+
"div.tsd-page-title": [
7+
{
8+
"tag": "ul.tsd-breadcrumb",
9+
"props": {
10+
"aria-label": "Breadcrumb"
11+
},
12+
"children": {
13+
"li": {
14+
"tag": "a",
15+
"props": {
16+
"href": "",
17+
"aria-current": "page"
18+
},
19+
"children": "BaseClass"
20+
}
21+
}
22+
},
23+
{
24+
"h1": "Class BaseClass"
25+
}
26+
]
27+
},
28+
{
29+
"tag": "section.tsd-panel.tsd-hierarchy",
30+
"props": {
31+
"data-refl": "8"
32+
},
33+
"children": [
34+
{
35+
"h4": [
36+
"Hierarchy (",
37+
{
38+
"tag": "a",
39+
"props": {
40+
"href": "../hierarchy.html#BaseClass"
41+
},
42+
"children": "View Summary"
43+
},
44+
")"
45+
]
46+
},
47+
{
48+
"ul.tsd-hierarchy": {
49+
"li.tsd-hierarchy-item": [
50+
{
51+
"span.tsd-hierarchy-target": "BaseClass"
52+
},
53+
{
54+
"ul.tsd-hierarchy": {
55+
"li.tsd-hierarchy-item": {
56+
"tag": "a.tsd-signature-type.tsd-kind-class",
57+
"props": {
58+
"href": "RenderClass.json"
59+
},
60+
"children": "RenderClass"
61+
}
62+
}
63+
}
64+
]
65+
}
66+
}
67+
]
68+
},
69+
{
70+
"section.tsd-panel-group.tsd-index-group": {
71+
"section.tsd-panel.tsd-index-panel": {
72+
"tag": "details.tsd-index-content.tsd-accordion",
73+
"props": {
74+
"open": true
75+
},
76+
"children": [
77+
{
78+
"summary.tsd-accordion-summary.tsd-index-summary": {
79+
"tag": "h5.tsd-index-heading.uppercase",
80+
"props": {
81+
"role": "button",
82+
"aria-expanded": "false",
83+
"tabIndex": "0"
84+
},
85+
"children": " Index"
86+
}
87+
},
88+
{
89+
"div.tsd-accordion-details": {
90+
"section.tsd-index-section": [
91+
{
92+
"h3.tsd-index-heading": "Constructors"
93+
},
94+
{
95+
"div.tsd-index-list": [
96+
{
97+
"tag": "a.tsd-index-link",
98+
"props": {
99+
"href": "#constructor"
100+
},
101+
"children": {
102+
"span": "constructor"
103+
}
104+
},
105+
"\n"
106+
]
107+
}
108+
]
109+
}
110+
}
111+
]
112+
}
113+
}
114+
},
115+
{
116+
"tag": "details.tsd-panel-group.tsd-member-group.tsd-accordion",
117+
"props": {
118+
"open": true
119+
},
120+
"children": [
121+
{
122+
"tag": "summary.tsd-accordion-summary",
123+
"props": {
124+
"data-key": "section-Constructors"
125+
},
126+
"children": {
127+
"h2": " Constructors"
128+
}
129+
},
130+
{
131+
"section": {
132+
"section.tsd-panel.tsd-member": [
133+
{
134+
"tag": "h3.tsd-anchor-link",
135+
"props": {
136+
"id": "constructor"
137+
},
138+
"children": [
139+
{
140+
"span": "constructor"
141+
},
142+
{
143+
"tag": "a.tsd-anchor-icon",
144+
"props": {
145+
"href": "#constructor",
146+
"aria-label": "Permalink"
147+
}
148+
}
149+
]
150+
},
151+
{
152+
"ul.tsd-signatures": {
153+
"li.": [
154+
{
155+
"tag": "div.tsd-signature.tsd-anchor-link",
156+
"props": {
157+
"id": "constructorbaseclass"
158+
},
159+
"children": [
160+
{
161+
"span.tsd-signature-keyword": "new"
162+
},
163+
" ",
164+
{
165+
"span.tsd-kind-constructor-signature": "BaseClass"
166+
},
167+
{
168+
"span.tsd-signature-symbol": "()"
169+
},
170+
{
171+
"span.tsd-signature-symbol": ":"
172+
},
173+
" ",
174+
{
175+
"tag": "a.tsd-signature-type.tsd-kind-class",
176+
"props": {
177+
"href": ""
178+
},
179+
"children": "BaseClass"
180+
},
181+
{
182+
"tag": "a.tsd-anchor-icon",
183+
"props": {
184+
"href": "#constructorbaseclass",
185+
"aria-label": "Permalink"
186+
}
187+
}
188+
]
189+
},
190+
{
191+
"div.tsd-description": {
192+
"h4.tsd-returns-title": [
193+
"Returns ",
194+
{
195+
"tag": "a.tsd-signature-type.tsd-kind-class",
196+
"props": {
197+
"href": ""
198+
},
199+
"children": "BaseClass"
200+
}
201+
]
202+
}
203+
}
204+
]
205+
}
206+
}
207+
]
208+
}
209+
}
210+
]
211+
}
212+
]
213+
},
214+
{
215+
"div.col-sidebar": {
216+
"div.page-menu": {
217+
"tag": "details.tsd-accordion.tsd-page-navigation",
218+
"props": {
219+
"open": true
220+
},
221+
"children": [
222+
{
223+
"summary.tsd-accordion-summary": {
224+
"h3": "On This Page"
225+
}
226+
},
227+
{
228+
"div.tsd-accordion-details": {
229+
"tag": "details.tsd-accordion.tsd-page-navigation-section",
230+
"props": {
231+
"open": true
232+
},
233+
"children": [
234+
{
235+
"tag": "summary.tsd-accordion-summary",
236+
"props": {
237+
"data-key": "section-Constructors"
238+
},
239+
"children": "Constructors"
240+
},
241+
{
242+
"div": {
243+
"tag": "a",
244+
"props": {
245+
"href": "#constructor"
246+
},
247+
"children": {
248+
"span": "constructor"
249+
}
250+
}
251+
}
252+
]
253+
}
254+
}
255+
]
256+
}
257+
}
258+
}
259+
]
260+
}

0 commit comments

Comments
 (0)