dwyl / learn-elm-architecture-in-javascript

:unicorn: Learn how to build web apps using the Elm Architecture in "vanilla" JavaScript (step-by-step TDD tutorial)!
https://todomvc-app.herokuapp.com
GNU General Public License v2.0
213 stars 19 forks source link

1. No Todos, should hide #footer and #main #56

Closed nelsonic closed 6 years ago

nelsonic commented 6 years ago

When there are No Todos, do not display the #main (list of todos) or footer (navigation): image

refer to the 1st test on this list: https://github.com/tastejs/todomvc/tree/master/tests#example-output

Test

Add the following test to your test/todo-app.test.js file:

test.only('No Todos, should hide #footer and #main', function (t) {
  // render the view and append it to the DOM inside the `test-app` node:
  document.getElementById(id).appendChild(app.view({todos: []})); // No Todos

  const main_display = window.getComputedStyle(document.getElementById('main'));
  t.equal('none', main_display._values.display, "No Todos, hide #main");

  const main_footer= window.getComputedStyle(document.getElementById('footer'));
  t.equal('none', main_footer._values.display, "No Todos, hide #footer");

  elmish.empty(document.getElementById(id)); // clear DOM ready for next test
  t.end();
});
nelsonic commented 6 years ago

image

nelsonic commented 6 years ago

Totes passing: image

nelsonic commented 6 years ago

image no-todos-hide-main-and-footer