-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
Copy pathwebbrowser.test.ts
36 lines (33 loc) · 1.37 KB
/
webbrowser.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
27
28
29
30
31
32
33
34
35
36
import { test, expect, describe } from "@jest/globals";
import { readFileSync } from "fs";
import { getText, parseInputs } from "../webbrowser.js";
describe("webbrowser Test suite", () => {
const html = readFileSync("./src/tools/fixtures/wordoftheday.html", "utf8");
test("parse html to text and links", async () => {
const baseUrl = "https://www.merriam-webster.com/word-of-the-day";
const text = getText(html, baseUrl, false);
expect(text).toContain("Word of the Day: Foible");
});
test("parseInputs", () => {
expect(
parseInputs(`"https://www.merriam-webster.com/word-of-the-day",""`)
).toEqual(["https://www.merriam-webster.com/word-of-the-day", ""]);
expect(
parseInputs(
`"https://www.merriam-webster.com/word-of-the-day","word of the day"`
)
).toEqual([
"https://www.merriam-webster.com/word-of-the-day",
"word of the day",
]);
expect(
parseInputs(`"https://www.merriam-webster.com/word-of-the-day","`)
).toEqual(["https://www.merriam-webster.com/word-of-the-day", ""]);
expect(
parseInputs(`"https://www.merriam-webster.com/word-of-the-day",`)
).toEqual(["https://www.merriam-webster.com/word-of-the-day", ""]);
expect(
parseInputs(`"https://www.merriam-webster.com/word-of-the-day"`)
).toEqual(["https://www.merriam-webster.com/word-of-the-day", undefined]);
});
});