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