Skip to content

Commit 5a7f464

Browse files
committed
test: add more tests for declarationSignatureToHtml
1 parent 60f4e6e commit 5a7f464

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

lib/declaration-signature-to-html.test.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,25 @@ test("variable", async () => {
2020
);
2121
});
2222

23+
test("class constructor", async () => {
24+
await expect(
25+
declarationSignatureToHtml(
26+
{
27+
kind: "class-constructor",
28+
id: "Foo.constructor",
29+
name: "constructor",
30+
docs: [],
31+
file: "foo.ts",
32+
line: 123,
33+
signature: "constructor() {}",
34+
},
35+
(s) => undefined,
36+
),
37+
).resolves.toMatchInlineSnapshot(
38+
`"<pre class="shiki shiki-themes github-light github-dark" style="background-color:#f7f7f7;--shiki-dark-bg:#24292e;color:#24292e;--shiki-dark:#e1e4e8" tabindex="0"><code><span class="line"><span style="color:#D73A49;--shiki-dark:#F97583">constructor</span><span style="color:#24292E;--shiki-dark:#E1E4E8">() {}</span></span></code></pre>"`,
39+
);
40+
});
41+
2342
test("class property", async () => {
2443
await expect(
2544
declarationSignatureToHtml(
@@ -57,3 +76,37 @@ test("don't link from function parameter name", async () => {
5776
`"<pre class="shiki shiki-themes github-light github-dark" style="background-color:#f7f7f7;--shiki-dark-bg:#24292e;color:#24292e;--shiki-dark:#e1e4e8" tabindex="0"><code><span class="line"><span style="color:#24292E;--shiki-dark:#E1E4E8">(</span><span style="color:#E36209;--shiki-dark:#FFAB70">bar</span><span style="color:#D73A49;--shiki-dark:#F97583">:</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> </span><a style="color:#6F42C1;--shiki-dark:#B392F0" href="bar.ts#L789">Bar</a><span style="color:#24292E;--shiki-dark:#E1E4E8">) </span><span style="color:#D73A49;--shiki-dark:#F97583">=&gt;</span><span style="color:#24292E;--shiki-dark:#E1E4E8"> </span><a style="color:#6F42C1;--shiki-dark:#B392F0" href="bar.ts#L789">Bar</a><span style="color:#24292E;--shiki-dark:#E1E4E8">;</span></span></code></pre>"`,
5877
);
5978
});
79+
80+
test("signature too long", async () => {
81+
await expect(
82+
declarationSignatureToHtml(
83+
{
84+
kind: "variable",
85+
id: "foo",
86+
name: "foo",
87+
docs: [],
88+
file: "foo.ts",
89+
line: 123,
90+
signature: "a".repeat(4000),
91+
},
92+
(s) => undefined,
93+
),
94+
).resolves.toBeDefined();
95+
});
96+
97+
test("empty signature", async () => {
98+
await expect(
99+
declarationSignatureToHtml(
100+
{
101+
kind: "variable",
102+
id: "foo",
103+
name: "foo",
104+
docs: [],
105+
file: "foo.ts",
106+
line: 123,
107+
signature: "",
108+
},
109+
(s) => undefined,
110+
),
111+
).resolves.toMatchInlineSnapshot(`"<pre class="shiki shiki-themes github-light github-dark" style="background-color:#f7f7f7;--shiki-dark-bg:#24292e;color:#24292e;--shiki-dark:#e1e4e8" tabindex="0"><code><span class="line"></span></code></pre>"`);
112+
});

0 commit comments

Comments
 (0)