-
Notifications
You must be signed in to change notification settings - Fork 3
/
htmlAssembler.test.js
62 lines (45 loc) · 1.71 KB
/
htmlAssembler.test.js
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
57
58
59
60
61
62
/*global test, expect */
const htmlAssembler = require("./htmlAssembler");
test("Adds lines, text input, stylesheet, and language", () => {
expect(
htmlAssembler("line", "nameOfTheFile", "StyleSheet", "Language")
).toBeDefined();
});
test("Accept all empty Strings", () => {
expect(htmlAssembler("", "", "", "")).toBeDefined();
});
test("Missing one argument still works", () => {
expect(htmlAssembler("", "", "")).toBeDefined();
});
test("Missing 2 Arguments still works", () => {
expect(htmlAssembler("", "")).toBeDefined();
});
test("Missing 3 Arguments still works", () => {
expect(htmlAssembler("")).toBeDefined();
});
test("Missing all Arguments Throws", () => {
expect(() => htmlAssembler()).toThrow();
});
test("Null Argument should throw", () => {
expect(() => htmlAssembler(null)).toThrow();
});
test("html should contain passed lang", () => {
let output = htmlAssembler("", "", "", "fake_lang");
expect(output).toContain(`<html lang="fake_lang">`);
});
test("html should contain passed stylesheet URI", () => {
let output = htmlAssembler("", "", "fake_style_sheet", "");
expect(output).toContain(`<link rel="stylesheet" href="fake_style_sheet"></link>`);
});
test("h1 should be present", () => {
let output = htmlAssembler("Heading 1\r\n\r\nParagraph", "test.txt", "", "");
expect(output).toContain("<h1>Heading 1</h1>");
});
test("title should be present", () => {
let output = htmlAssembler("Title text\r\n\r\nParagraph", "test.txt", "", "");
expect(output).toContain("<title>Title text</title>");
});
test("paragraph should be present", () => {
let output = htmlAssembler("Title text\r\n\r\nParagraph text", "test.txt", "", "");
expect(output).toContain("<p>Paragraph text</p>");
});