Skip to content

Commit dd51dcb

Browse files
committed
add (human readable) Acceptance Criteria and Test Assertions for "main" List view #51
1 parent afaed24 commit dd51dcb

File tree

3 files changed

+74
-2
lines changed

3 files changed

+74
-2
lines changed

Diff for: examples/todo-list/elmish.js

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ function empty(node) {
1414
}
1515
} // this function produces a (DOM) "mutation" but has no other "side effects".
1616

17-
18-
1917
/**
2018
* `mount` mounts the app in the "root" DOM Element.
2119
* @param {Object} model store of the application's state.

Diff for: examples/todo-list/todo-app.js

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ function update(action, model, data) {
4242
return new_model;
4343
}
4444

45+
46+
4547
// function view(signal, model, root) {
4648
// empty(root); // clear root element before re-rendering the App (DOM).
4749
// model.counters.map(function(counter, index) {

Diff for: todo-list.md

+72
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,78 @@ and _just_ focus on rendering the _list_ itself.
719719
![todomvc-3-items-1-done](https://user-images.githubusercontent.com/194400/43690122-b72bcb0e-98fc-11e8-83c2-8b8703b177ed.png)
720720

721721

722+
In your web browser, open **Dev**eloper **Tools**
723+
and _inspect_ the HTML for the Todo list:
724+
725+
![todomvc-main-section-todo-list-html](https://user-images.githubusercontent.com/194400/43717480-9fb80982-997f-11e8-9ffe-6aa90a89a042.png)
726+
727+
This is the HTML copied directly from the browser:
728+
```html
729+
<section class="main" style="display: block;">
730+
<input class="toggle-all" type="checkbox">
731+
<label for="toggle-all">Mark all as complete</label>
732+
<ul class="todo-list">
733+
<li data-id="1533501855500" class="completed">
734+
<div class="view">
735+
<input class="toggle" type="checkbox">
736+
<label>Learn Elm Architecture</label>
737+
<button class="destroy"></button>
738+
</div>
739+
</li>
740+
<li data-id="1533501861171" class="">
741+
<div class="view">
742+
<input class="toggle" type="checkbox">
743+
<label>Build Todo List App</label>
744+
<button class="destroy"></button>
745+
</div>
746+
</li>
747+
<li data-id="1533501867123" class="">
748+
<div class="view"><input class="toggle" type="checkbox">
749+
<label>Win the Internet!</label>
750+
<button class="destroy"></button>
751+
</div>
752+
</li>
753+
</ul>
754+
</section>
755+
```
756+
> _**Note**: there is "redundant" markup in this HTML in the form of a `<div>`
757+
inside the `<li>`, for now we are just replicating the HTML "faithfully",
758+
we can "prune" it later._
759+
760+
From this HTMl we can write our
761+
["**_Technical_ Acceptance Criteria**"](https://github.com/dwyl/learn-elm-architecture-in-javascript/issues/51):
762+
763+
+ [ ] Todo List items should be displayed as list items **`<li>`**
764+
in an _unordered list_ **`<ul>`**.
765+
+ [ ] Each Todo List item **`<li>`** should contain a **`<div>`**
766+
with a **`class="view"`** which "wraps":
767+
+ [ ] **`<input class="toggle" type="checkbox">`** - the "checkbox"
768+
that people can "Toggle" to change the "state"
769+
of the Todo item from "active" to "done"
770+
(_which updates the model
771+
From: `model.todos[id].done=false`
772+
To: `model.todos[id].done=true`_)
773+
+ [ ] **`<label>`** - the text content of the todo list item
774+
+ [ ] **`<button class="destroy">`** - the button the person
775+
can click/tap to **`delete`** a Todo item.
776+
777+
778+
### Todo List `view` Test Assertions
779+
780+
Given the `model` (_above_),
781+
+ [ ] There is a `<ul class="todo-list">` with 3 **`<li>`** (_list items_)
782+
rendered in the `view`.
783+
+ [ ] The ***first*** **`<li>`** has an **`<input type="checkbox">`**
784+
which is _checked_ (`done=true`)
785+
+ [ ] The ***remaining*** **`<li>'s`** have **`<input type="checkbox">`**
786+
that are _unchecked_ (`done=false`)
787+
788+
789+
We can _easily_ write a _test_ that includes these 3 assertions:
790+
791+
792+
793+
722794

723795
<!--
724796

0 commit comments

Comments
 (0)