-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
68 lines (64 loc) · 2.25 KB
/
script.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
63
64
65
66
67
68
/* =================
TESTS, LOOK AT THESE
Reading tests will always help you discover your requirements.
You can make this window bigger.
===================
*/
const {
core: { test, expect, run },
prettify
} = window.jestLite;
/* =================
FIND ELEMENTS
These are all the elements we will look for.
===================
*/
const getHeader = document.querySelectorAll("header"),
getH1 = document.querySelectorAll("h1"),
getSiteHeader = document.querySelectorAll(".c-site-header"),
getAria = document.querySelectorAll('nav[aria-label="Main Site Links."]'),
getMain = document.querySelectorAll("main"),
getFooter = document.querySelectorAll("footer"),
getSiteFooter = document.querySelectorAll(".c-site-footer"),
getIFrame = document.querySelectorAll("iframe"),
getImage = document.querySelectorAll("img"),
getWords = document.body.innerText;
/* =================
ASSERTIONS
These are the things we check are true about your page.
Read and update your HTML to discover the requirements.
The tests will run every time you update your code.
===================
*/
test("There is at least one header element", () => {
expect(getHeader.length).toBeGreaterThanOrEqual(1);
});
test("There is at least one h1", () => {
expect(getH1.length).toBeGreaterThanOrEqual(1);
});
test("There is only one header element with the class c-site-header", () => {
expect(getSiteHeader.length).toBe(1);
});
test("There is a nav element with an aria-label of Main Site Links.", () => {
expect(getAria.length).toBeGreaterThanOrEqual(1);
});
test("There is only one main element", () => {
expect(getMain.length).toBe(1);
});
test("There is at least one footer element", () => {
expect(getFooter.length).toBeGreaterThanOrEqual(1);
});
test("There is only one footer element with the class c-site-footer", () => {
expect(getSiteFooter.length).toBe(1);
});
test("There is embedded video", () => {
expect(getIFrame.length).toBeGreaterThanOrEqual(1);
});
test("There is at least one image", () => {
expect(getImage.length).toBeGreaterThanOrEqual(1);
});
test("There are at least 500 words on the page", () => {
expect(getWords.length).toBeGreaterThanOrEqual(500);
});
const console = document.getElementById("tests");
prettify.toHTML(run(), console);