Skip to content

Commit e672653

Browse files
committed
test: add test for declarationUrl
1 parent 761c6c1 commit e672653

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

lib/declaration-url.test.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { expect, test } from "vitest";
2+
import { makeDeclarationUrl } from "./declaration-url";
3+
4+
test("declarationUrl", () => {
5+
const declarationUrl = makeDeclarationUrl([
6+
{
7+
kind: "variable",
8+
id: "foo",
9+
name: "foo",
10+
docs: [],
11+
file: "foo.ts",
12+
line: 123,
13+
signature: "const foo: Foo;",
14+
},
15+
{
16+
kind: "namespace",
17+
id: "bar",
18+
name: "bar",
19+
docs: [],
20+
file: "bar.ts",
21+
line: 456,
22+
signature: "",
23+
declarations: [
24+
{
25+
kind: "variable",
26+
id: "bar.qux",
27+
name: "qux",
28+
docs: [],
29+
file: "qux.ts",
30+
line: 789,
31+
signature: "const qux: Qux;",
32+
},
33+
],
34+
},
35+
]);
36+
expect(declarationUrl("Awaited")).toMatchInlineSnapshot(
37+
`"https://www.typescriptlang.org/docs/handbook/utility-types.html#awaitedtype"`,
38+
);
39+
expect(declarationUrl("foo")).toMatchInlineSnapshot(`"#foo"`);
40+
expect(declarationUrl("qux")).toMatchInlineSnapshot(`"#bar.qux"`);
41+
});

0 commit comments

Comments
 (0)