dwyl / dwyl/javascript-todo-list-tutorial
Elmish tutorial: mount test errors
- Dominant language
- JavaScript
- Stars
- 799
- Forks
- 138
- Avg merge
- 7h 14m
- Merged PRs (30d)
- 4
Description
I discovered some errors in the `elmish.md` walkthrough at the [mount step](https://github.com/dwyl/javascript-todo-list-tutorial/blob/master/elmish.md#mount-the-app). To be clear, when I run the tests for the final version of `elmish.js` as given in the repo, everything passes, so these errors are against an intermediate step in the text of `elmish.md` only.
1. Entering the code as given through the `mount` implementation section produces the following:

This stems from the test call to [`elmish.mount`](https://github.com/dwyl/javascript-todo-list-tutorial/blob/6e24b39b510dfee84d1ef31d63b8e00904e346fa/test/elmish.test.js#L38). It looks as if the order of the arguments to `view` are in the wrong order; the instances specifically are: a) the call to `view` in the `mount` function [within the `elmish.md` text](https://github.com/dwyl/javascript-todo-list-tutorial/blob/master/elmish.md#mount-function-implementation) and b) in the [`counter.js` declaration of `view`](https://github.com/dwyl/javascript-todo-list-tutorial/blob/6e24b39b510dfee84d1ef31d63b8e00904e346fa/test/counter.js#L19). The arity of the call compared to the declaration also differs.
FWIW, to fix I switched the order of the args in `counter.js` (the final version of `elmish.js` seemed to indicate that was the way). This eliminates the `TypeError` for 'signal not a function', but running the tests leads to another error:
2. The first test for the assert against the state of the counter fails, and the button seems not to be in the (js)DOM:

The `view` function returns a [`container`](https://github.com/dwyl/javascript-todo-list-tutorial/blob/6e24b39b510dfee84d1ef31d63b8e00904e346fa/test/counter.js#L74), but it doesn't seem to be appended? When I call `document.appendChild` on each of the two calls to `view` in `mount`, the tests pass.
I am on Ubuntu 20.04, node 14.15.1.
Contributor guide
Assessment
This issue has not been assessed yet.