4 Test to verify the delete button calls the onDelete handler for an item
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">
13 <div id=
"container"></div>
16 <script src=
"head.js" type=
"application/javascript"></script>
17 <script type=
"application/javascript">
19 window.onload = async function() {
21 const container = document.getElementById(
"container");
23 const deletedSnapshots = [];
25 const snapshots = [ TEST_SNAPSHOT, TEST_SNAPSHOT, TEST_SNAPSHOT ]
26 .map((snapshot, index) =
> immutableUpdate(snapshot, {
27 index: snapshot.index + index,
30 await renderComponent(
32 itemComponent: SnapshotListItem,
34 onDelete: (item) =
> deletedSnapshots.push(item),
40 const deleteButtons = container.querySelectorAll(
".delete");
42 is(container.querySelectorAll(
".snapshot-list-item").length,
3,
43 "There are 3 list items\n");
44 is(deletedSnapshots.length,
0,
45 "Not snapshots have been deleted\n");
47 deleteButtons[
1].click();
49 is(deletedSnapshots.length,
1,
"One snapshot was deleted\n");
50 is(deletedSnapshots[
0], snapshots[
1],
51 "Deleted snapshot was added to the deleted list\n");
53 deleteButtons[
0].click();
55 is(deletedSnapshots.length,
2,
"Two snapshots were deleted\n");
56 is(deletedSnapshots[
1], snapshots[
0],
57 "Deleted snapshot was added to the deleted list\n");
59 deleteButtons[
2].click();
61 is(deletedSnapshots.length,
3,
"Three snapshots were deleted\n");
62 is(deletedSnapshots[
2], snapshots[
2],
63 "Deleted snapshot was added to the deleted list\n");
65 ok(false,
"Got an error: " + DevToolsUtils.safeErrorString(e));