Skip to content

Commit

Permalink
reorder New Todo test assertions for clarity #55
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Aug 9, 2018
1 parent 7b56e55 commit f37c398
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions test/todo-app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,16 @@ test('2. New Todo, should allow me to add todo items', function (t) {
new_todo.dispatchEvent(new KeyboardEvent('keypress', {'keyCode': 13}));
const items = document.querySelectorAll('.view');

// subscription keyCode trigger "branch" test (should NOT fire the signal):
const clone = document.getElementById(id).cloneNode(true);
new_todo.dispatchEvent(new KeyboardEvent('keypress', {'keyCode': 42}));
t.deepEqual(document.getElementById(id), clone, "#" + id + " no change");

t.equal(items.length, 1, "should allow me to add todo items");
// check if the new todo was added to the DOM:
const actual = document.getElementById('1').textContent;
t.equal(todo_text.trim(), actual, "should trim text input")

// subscription keyCode trigger "branch" test (should NOT fire the signal):
const clone = document.getElementById(id).cloneNode(true);
new_todo.dispatchEvent(new KeyboardEvent('keypress', {'keyCode': 42}));
t.deepEqual(document.getElementById(id), clone, "#" + id + " no change");

// check that the <input id="new-todo"> was reset after the new item was added
t.equal(new_todo.value, '',
"should clear text input field when an item is added")
Expand Down
10 changes: 5 additions & 5 deletions todo-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -1476,16 +1476,16 @@ test('2. New Todo, should allow me to add todo items', function (t) {
new_todo.dispatchEvent(new KeyboardEvent('keypress', {'keyCode': 13}));
const items = document.querySelectorAll('.view');

// subscription keyCode trigger "branch" test (should NOT fire the signal):
const clone = document.getElementById(id).cloneNode(true);
new_todo.dispatchEvent(new KeyboardEvent('keypress', {'keyCode': 42}));
t.deepEqual(document.getElementById(id), clone, "#" + id + " no change");

t.equal(items.length, 1, "should allow me to add todo items");
// check if the new todo was added to the DOM:
const actual = document.getElementById('1').textContent;
t.equal(todo_text.trim(), actual, "should trim text input")

// subscription keyCode trigger "branch" test (should NOT fire the signal):
const clone = document.getElementById(id).cloneNode(true);
new_todo.dispatchEvent(new KeyboardEvent('keypress', {'keyCode': 42}));
t.deepEqual(document.getElementById(id), clone, "#" + id + " no change");

// check that the <input id="new-todo"> was reset after the new item was added
t.equal(new_todo.value, '',
"should clear text input field when an item is added")
Expand Down

0 comments on commit f37c398

Please sign in to comment.