-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.spec.ts
56 lines (48 loc) · 1.49 KB
/
test.spec.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { describe, expect, test } from "bun:test";
import resumeSchema from "resume-schema";
import {
dateToDay,
dateToMonthName,
dateToYear,
iconify,
markdown,
} from "./build-html";
const cv_path = "cv.json";
const cv_file = Bun.file(cv_path);
const cv = await cv_file.json();
test("cv is valid to schema", async () => {
let error: Error | null = null;
let report: string | null = null;
await resumeSchema.validate(cv, function (err: Error, report: string) {
error = err;
report = report;
expect(err).toBeNull();
});
});
describe("helpers", () => {
test("dateToYear", () => {
expect(dateToYear("2020-12-25")).toBe("2020");
expect(dateToYear("1970-6-1")).toBe("1970");
});
test("dateToMonthName", () => {
expect(dateToMonthName("2020-12-25")).toBe("December");
expect(dateToMonthName("1970-6-1")).toBe("June");
});
test("dateToDay", () => {
expect(dateToDay("2020-12-25")).toBe("25");
expect(dateToDay("1970-6-1")).toBe("1");
expect(dateToDay("1970-6-07")).toBe("7");
});
test("iconify", () => {
expect(iconify("blog")).toBe("fas fa-rss");
expect(iconify("github")).toBe("fab fa-github");
expect(iconify("unknown")).toBe("fab fa-unknown");
});
test("markdown", () => {
expect(markdown("Hello, world!")).toBe("<p>Hello, world!</p>\n");
expect(markdown("# Hello, world!")).toBe("<h1>Hello, world!</h1>\n");
expect(markdown("Hello, **world**!")).toBe(
"<p>Hello, <strong>world</strong>!</p>\n"
);
});
});