dwyl / dwyl/javascript-todo-list-tutorial

Elmish tutorial: mount test errors

Đang mở
#31 2 bình luận 1 reaction 0 người được giao Xem trên GitHub
bug help wanted starter technical
Ngôn ngữ chính
JavaScript
Star
799
Fork
138
Merge trung bình
7 giờ 14 phút
Pull request đã merge (30 ngày)
4

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.