|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Makes sure Table Charts correctly handle empty source data. |
|
6 */ |
|
7 |
|
8 function test() { |
|
9 initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { |
|
10 info("Starting test... "); |
|
11 |
|
12 let { document, L10N, Chart } = aMonitor.panelWin; |
|
13 let container = document.createElement("box"); |
|
14 |
|
15 let table = Chart.Table(document, { |
|
16 data: [], |
|
17 totals: { |
|
18 label1: value => "Hello " + L10N.numberWithDecimals(value, 2), |
|
19 label2: value => "World " + L10N.numberWithDecimals(value, 2) |
|
20 } |
|
21 }); |
|
22 |
|
23 let node = table.node; |
|
24 let grid = node.querySelector(".table-chart-grid"); |
|
25 let totals = node.querySelector(".table-chart-totals"); |
|
26 let rows = grid.querySelectorAll(".table-chart-row"); |
|
27 let sums = node.querySelectorAll(".table-chart-summary-label"); |
|
28 |
|
29 is(rows.length, 1, |
|
30 "There should be 1 table chart row created."); |
|
31 |
|
32 ok(rows[0].querySelector(".table-chart-row-box.chart-colored-blob"), |
|
33 "A colored blob exists for the firt row."); |
|
34 is(rows[0].querySelectorAll("label")[0].getAttribute("name"), "size", |
|
35 "The first column of the first row exists."); |
|
36 is(rows[0].querySelectorAll("label")[1].getAttribute("name"), "label", |
|
37 "The second column of the first row exists."); |
|
38 is(rows[0].querySelectorAll("label")[0].getAttribute("value"), "", |
|
39 "The first column of the first row displays the correct text."); |
|
40 is(rows[0].querySelectorAll("label")[1].getAttribute("value"), L10N.getStr("tableChart.unavailable"), |
|
41 "The second column of the first row displays the correct text."); |
|
42 |
|
43 is(sums.length, 2, |
|
44 "There should be 2 total summaries created."); |
|
45 |
|
46 is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("name"), "label1", |
|
47 "The first sum's type is correct."); |
|
48 is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("value"), "Hello 0", |
|
49 "The first sum's value is correct."); |
|
50 |
|
51 is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("name"), "label2", |
|
52 "The second sum's type is correct."); |
|
53 is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("value"), "World 0", |
|
54 "The second sum's value is correct."); |
|
55 |
|
56 teardown(aMonitor).then(finish); |
|
57 }); |
|
58 } |