@@ -1382,6 +1382,7 @@ We are going to write each one of these tests and then
1382
1382
1383
1383
#### 1. No Todos, should hide #footer and #main
1384
1384
1385
+
1385
1386
Add the following test to your ` test/todo-app.test.js ` file:
1386
1387
``` js
1387
1388
test .only (' 1. No Todos, should hide #footer and #main' , function (t ) {
@@ -1638,6 +1639,73 @@ Try and make this test pass by yourself before consulting the
1638
1639
sample code:
1639
1640
[ ** ` examples/todo-list/todo-app.js ` ** ] ( https://github.com/dwyl/learn-elm-architecture-in-javascript/pull/45/files#diff-6be3e16fe7cfb4c00788d4d587374afdR46 )
1640
1641
1642
+
1643
+ ### 4. Item
1644
+
1645
+ ```
1646
+ 4. Item
1647
+ ✓ should allow me to mark items as complete (843ms)
1648
+ ✓ should allow me to un-mark items as complete (978ms)
1649
+ ✓ should allow me to edit an item (1155ms)
1650
+ ✓ should show the remove button on hover
1651
+ ```
1652
+
1653
+ Of these requirements, we already have the first two "_ covered_ "
1654
+ because we implemented the ` TOGGLE ` feature (_ above_ ).
1655
+
1656
+ We can add another "proxy" test just for "_ completeness_ ":
1657
+
1658
+ ``` js
1659
+ test .only (' 4. Item: should allow me to mark items as complete' , function (t ) {
1660
+ elmish .empty (document .getElementById (id));
1661
+ localStorage .removeItem (' elmish_' + id);
1662
+ const model = {
1663
+ todos: [
1664
+ { id: 0 , title: " Make something people want." , done: false }
1665
+ ],
1666
+ hash: ' #/' // the "route" to display
1667
+ };
1668
+ // render the view and append it to the DOM inside the `test-app` node:
1669
+ elmish .mount (model, app .update , app .view , id, app .subscriptions );
1670
+ const item = document .getElementById (' 0' )
1671
+ t .equal (item .textContent , model .todos [0 ].title , ' Item contained in model.' );
1672
+ // confirm that the todo item is NOT done (done=false):
1673
+ t .equal (document .querySelectorAll (' .toggle' )[0 ].checked , false ,
1674
+ ' Item starts out "active" (done=false)' );
1675
+
1676
+
1677
+ // click the checkbox to toggle it to done=true
1678
+ document .querySelectorAll (' .toggle' )[0 ].click ()
1679
+ t .equal (document .querySelectorAll (' .toggle' )[0 ].checked , true ,
1680
+ ' Item should allow me to mark items as complete' );
1681
+
1682
+ // click the checkbox to toggle it to done=false "undo"
1683
+ document .querySelectorAll (' .toggle' )[0 ].click ()
1684
+ t .equal (document .querySelectorAll (' .toggle' )[0 ].checked , false ,
1685
+ ' Item should allow me to un-mark items as complete' );
1686
+ t .end ();
1687
+ });
1688
+ ```
1689
+ You should not need to write any additional code
1690
+ in order to make this test pass; just run it and move on.
1691
+
1692
+ ![ toggle-todo-tests-passing] ( https://user-images.githubusercontent.com/194400/43992979-a4d00ab6-9d7e-11e8-891b-9f699f474dd5.png )
1693
+
1694
+
1695
+
1696
+ #### 4.2 ` EDIT ` an Item
1697
+
1698
+ ```
1699
+ should allow me to edit an item
1700
+ ```
1701
+
1702
+ #### 4.1 ` DELETE ` an Item
1703
+
1704
+ ```
1705
+ should show the remove button on hover
1706
+ ```
1707
+
1708
+
1641
1709
<!--
1642
1710
1643
1711
## What _Next_?
0 commit comments