Skip to content

Commit 91efbbd

Browse files
committed
add assertions to main view test for #51
1 parent 6137d41 commit 91efbbd

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Diff for: todo-list.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -799,13 +799,17 @@ test('render "main" view using (elmish) HTML DOM functions', function (t) {
799799
],
800800
hash: '#/' // the "route" to display
801801
};
802-
const html = app.main(model);
803-
802+
// render the "main" view and append it to the DOM inside the `test-app` node:
803+
elmish.append_childnodes(app.render_main(model), document.getElementById(id));
804804
const done = document.querySelectorAll('.completed')[0].textContent;
805805
t.equal(done, 'Learn Elm Architecture', 'Done: Learn "TEA"');
806806
const todo = document.querySelectorAll('.view')[1].textContent;
807807
t.equal(todo, 'Build Todo List App', 'Todo: Build Todo List App');
808-
elmish.empty(document.getElementById(id));
808+
const todos = document.querySelectorAll('.toggle');
809+
[true, false, false].forEach(function(state, index){
810+
t.equal(todos.checked, state, "Todo #" + index + " is done=" + state)
811+
})
812+
elmish.empty(document.getElementById(id)); // clear DOM ready for next test
809813
t.end();
810814
});
811815
```

0 commit comments

Comments
 (0)