-
Notifications
You must be signed in to change notification settings - Fork 313
/
Copy pathtests.js
67 lines (49 loc) · 1.82 KB
/
tests.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
const fs = require('fs');
const path = require('path');
const html = fs.readFileSync(path.resolve(__dirname, './index.html'), 'utf8');
document.documentElement.innerHTML = html.toString();
jest.dontMock('fs');
it('You should create a <table> tag inside the <body>.', function () {
let body = document.querySelector("body");
expect(body).toBeTruthy();
let table = body.querySelector("table");
expect(table).toBeTruthy();
})
it('The <table> tag should have border="0".', function () {
let body = document.querySelector("body");
expect(body).toBeTruthy();
let table = body.querySelector("table");
expect(table).toBeTruthy();
expect(table.border).toBe("0");
})
it('The <table> tag should have a <tr> tag inside.', function () {
let body = document.querySelector("body");
expect(body).toBeTruthy();
let table = body.querySelector("table");
expect(table).toBeTruthy();
let tr = table.querySelector("tr");
expect(tr).toBeTruthy();
})
it('The <tr> tag should have 2 <td> tags inside.', function () {
let body = document.querySelector("body");
expect(body).toBeTruthy();
let table = body.querySelector("table");
expect(table).toBeTruthy();
let tr = table.querySelector("tr");
expect(tr).toBeTruthy();
let tds = tr.querySelectorAll("td");
expect(tds.length).toBe(2);
})
it('The first <td> tag should have an <img> tag inside, and a width of "25%".', function () {
let body = document.querySelector("body");
expect(body).toBeTruthy();
let table = body.querySelector("table");
expect(table).toBeTruthy();
let tr = table.querySelector("tr");
expect(tr).toBeTruthy();
let td = tr.querySelectorAll("td")[0];
expect(td).toBeTruthy();
expect(td.width).toBe("25%")
let img = td.querySelector("img");
expect(img).toBeTruthy();
})