dwyl / javascript-todo-list-tutorial

✅ A step-by-step complete beginner example/tutorial for building a Todo List App (TodoMVC) from scratch in JavaScript following Test Driven Development (TDD) best practice. 🌱
https://dwyl.github.io/javascript-todo-list-tutorial
GNU General Public License v2.0
629 stars 102 forks source link

Elmish tutorial: mount test errors #31

Open lederle opened 3 years ago

lederle commented 3 years ago

I discovered some errors in the elmish.md walkthrough at the mount step. 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:

Screenshot from 2021-02-11 19-48-05

This stems from the test call to elmish.mount. 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 and b) in the counter.js declaration of view. 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:

  1. The first test for the assert against the state of the counter fails, and the button seems not to be in the (js)DOM:

Screenshot from 2021-02-11 20-34-36

The view function returns a container, 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.

nelsonic commented 3 years ago

@lederle yeah, it appears to be a typo in the ordering rather than a defect. Stoked you found it. Hope it didn't cause you too much grief. 👍

nelsonic commented 1 year ago

PR welcome to fix this. 🙏