-
Notifications
You must be signed in to change notification settings - Fork 0
/
group_links_test.ts
26 lines (25 loc) · 1021 Bytes
/
group_links_test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { assert, assertFalse } from "./deps/std/assert.ts";
import { isGithubReadmeWithAnchorUrl } from "./group_links.ts";
Deno.test("isGithubReadmeWithAnchorUrl", async (t) => {
const goodLinks = [
"https://github.com/grammyjs/grammY#anchor",
"https://github.com/grammyjs/grammY/tree/main#anchor",
"https://github.com/grammyjs/grammY#readme", // it is ignored internally.
"https://github.com/grammyjs/grammY/tree/main/src#anchor",
];
for (const link of goodLinks) {
await t.step(link + " (true)", () => {
assert(isGithubReadmeWithAnchorUrl(new URL(link)));
});
}
const badLinks = [
"https://github.com/grammyjs/grammY",
"https://github.com/grammyjs/grammY/blob/main/file.md#anchor",
"https://github.com/grammyjs/grammY/tree#anchor",
];
for (const link of badLinks) {
await t.step(link + " (false)", () => {
assertFalse(isGithubReadmeWithAnchorUrl(new URL(link)));
});
}
});