test_CensusTreeItem_01.html (2493B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 Test that children pointers show up at the correct times. 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Tree component test</title> 9 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 10 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"> 11 </head> 12 <body> 13 <!-- Give the container height so that the whole tree is rendered. --> 14 <div id="container" style="height: 900px;"></div> 15 16 <pre id="test"> 17 <script src="head.js" type="application/javascript"></script> 18 <script type="application/javascript"> 19 "use strict"; 20 window.onload = async function() { 21 try { 22 const container = document.getElementById("container"); 23 24 await renderComponent(CensusTreeItem(immutableUpdate(TEST_CENSUS_TREE_ITEM_PROPS, { 25 inverted: true, 26 depth: 0, 27 })), container); 28 29 ok(!container.querySelector(".children-pointer"), 30 "Don't show children pointer for roots when we are inverted"); 31 32 await renderComponent(CensusTreeItem(immutableUpdate(TEST_CENSUS_TREE_ITEM_PROPS, { 33 inverted: true, 34 depth: 1, 35 })), container); 36 37 ok(container.querySelector(".children-pointer"), 38 "Do show children pointer for non-roots when we are inverted"); 39 40 await renderComponent(CensusTreeItem(immutableUpdate(TEST_CENSUS_TREE_ITEM_PROPS, { 41 inverted: false, 42 item: immutableUpdate(TEST_CENSUS_TREE_ITEM_PROPS.item, { children: undefined }), 43 })), container); 44 45 ok(!container.querySelector(".children-pointer"), 46 "Don't show children pointer when non-inverted and no children"); 47 48 await renderComponent(CensusTreeItem(immutableUpdate(TEST_CENSUS_TREE_ITEM_PROPS, { 49 inverted: false, 50 depth: 0, 51 item: immutableUpdate(TEST_CENSUS_TREE_ITEM_PROPS.item, { children: [{}] }), 52 })), container); 53 54 ok(container.querySelector(".children-pointer"), 55 "Do show children pointer when non-inverted and have children"); 56 } catch (e) { 57 ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e)); 58 } finally { 59 SimpleTest.finish(); 60 } 61 }; 62 </script> 63 </pre> 64 </body> 65 </html>