dwyl / dwyl/javascript-todo-list-tutorial

Elmish tutorial: mount test errors

Abierto
#31 2 comentarios 1 reacción 0 asignados Ver en GitHub
bug help wanted starter technical
Lenguaje dominante
JavaScript
Estrellas
799
Forks
138
Merge medio
7 h 14 min
PR fusionados (30 d)
4

Descripción

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:

![Screenshot from 2021-02-11 19-48-05](https://user-images.githubusercontent.com/1102813/107717711-4b5fbf80-6ca2-11eb-96f2-d63f4938a164.png)

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:

![Screenshot from 2021-02-11 20-34-36](https://user-images.githubusercontent.com/1102813/107720623-b8765380-6ca8-11eb-9cc6-ac64406ce9e8.png)

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.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.