-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrawl.test.js
More file actions
47 lines (40 loc) · 1.68 KB
/
crawl.test.js
File metadata and controls
47 lines (40 loc) · 1.68 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { test, expect } from "@jest/globals";
import { normalizeURL, getURLsFromHTML } from "./crawl.js";
test("https url normalization 1", () => {
expect(normalizeURL("https://blog.boot.dev/path/")).toBe(
"blog.boot.dev/path",
);
});
test("https url normalization 2", () => {
expect(normalizeURL("https://blog.boot.dev/path")).toBe("blog.boot.dev/path");
});
test("https url normalization 3", () => {
expect(normalizeURL("http://blog.boot.dev/path/")).toBe("blog.boot.dev/path");
});
test("https url normalization 4", () => {
expect(normalizeURL("http://blog.boot.dev/path")).toBe("blog.boot.dev/path");
});
test("https get url from html 1", () => {
let html =
'<html><body><a href="https://boot.dev">Learn Backend Development</a><a href="/leaderboard">rellink to leaderboard\
</a><a href="https://boot.dev/lore">Check out the lore</a>https</body></html>';
expect(getURLsFromHTML(html, "https://boot.dev")).toContain(
"https://boot.dev",
);
});
test("https get url from html 2", () => {
let html =
'<html><body><a href="https://boot.dev">Learn Backend Development</a><a href="/leaderboard">rellink to leaderboard\
</a><a href="https://boot.dev/lore">Check out the lore</a>https</body></html>';
expect(getURLsFromHTML(html, "https://boot.dev")).toContain(
"https://boot.dev/leaderboard",
);
});
test("https get url from html 3", () => {
let html =
'<html><body><a href="https://boot.dev">Learn Backend Development</a><a href="/leaderboard">rellink to leaderboard\
</a><a href="https://boot.dev/lore">Check out the lore</a>https</body></html>';
expect(getURLsFromHTML(html, "https://boot.dev")).toContain(
"https://boot.dev/lore",
);
});