forked from CUNYTechPrep/eloquentjs-problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchapter13.test.js
More file actions
32 lines (27 loc) · 1.07 KB
/
Copy pathchapter13.test.js
File metadata and controls
32 lines (27 loc) · 1.07 KB
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
const ch13 = require('./chapter13');
const data = [
{ name: "Kilimanjaro", height: 5895, country: "Tanzania" },
{ name: "Everest", height: 8848, country: "Nepal" },
{ name: "Mount Fuji", height: 3776, country: "Japan" },
{ name: "Mont Blanc", height: 4808, country: "Italy/France" },
];
/*
* This test demonstrates that Jest provides us access to a testing DOM.
* Here we inspect the generated table, using standard DOM calls
*/
describe('Ch.13, Problem 1: Build table', () => {
const buildTable = ch13.buildTable;
const table = buildTable(data);
test('buildTable(data) produced a table', () => {
expect(table.nodeName).toEqual('TABLE');
expect(table.children.length).toEqual(5);
const row1 = table.children[1];
expect(row1.nodeName).toEqual('TR');
expect(row1.children.length).toEqual(3);
const cols = row1.children;
expect(cols[0].nodeName).toEqual('TD');
expect(cols[0].textContent).toBe(data[0].name);
expect(parseInt(cols[1].textContent)).toBe(data[0].height);
expect(cols[2].textContent).toBe(data[0].country);
});
});