Skip to content

Commit a3e0644

Browse files
committed
fix failing test due to change in name of localstorage key for #57
1 parent 209d72d commit a3e0644

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

Diff for: examples/todo-list/todo-app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ function render_footer (model) {
149149
a(["href=#/completed"], [text("Completed")])
150150
])
151151
]), // </ul>
152-
button(["class=clear-completed", display_clear],
152+
button(["class=clear-completed", "onclick=alert('hello')"],
153153
[text("Clear completed")]
154154
)
155155
])

Diff for: test/elmish.test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ test('elmish.mount sets model in localStorage', function (t) {
392392
const root = document.getElementById(id);
393393
elmish.mount(7, update, view, id);
394394
// the "model" stored in localStorage should be 7 now:
395-
t.equal(JSON.parse(localStorage.getItem('elmish_store')), 7,
395+
t.equal(JSON.parse(localStorage.getItem('elmish_' + id)), 7,
396396
"elmish_store is 7 (as expected). initial state saved to localStorage.");
397397
// test that mount still works as expected (check initial state of counter):
398398
const actual = document.getElementById(id).textContent;
@@ -412,12 +412,12 @@ test('elmish.mount sets model in localStorage', function (t) {
412412
.textContent, 10);
413413
t.equal(state, 8, "State is 8 after increment.");
414414
// the "model" stored in localStorage should also be 8 now:
415-
t.equal(JSON.parse(localStorage.getItem('elmish_store')), 8,
415+
t.equal(JSON.parse(localStorage.getItem('elmish_' + id)), 8,
416416
"elmish_store is 8 (as expected).");
417417
elmish.empty(root); // reset the DOM to simulate refreshing a browser window
418418
elmish.mount(5, update, view, id); // 5 ignored! read model from localStorage
419419
// clearing DOM does NOT clear the localStorage (this is desired behaviour!)
420-
t.equal(JSON.parse(localStorage.getItem('elmish_store')), 8,
420+
t.equal(JSON.parse(localStorage.getItem('elmish_' + id)), 8,
421421
"elmish_store still 8 from increment (above) saved in localStorage");
422422
localStorage.removeItem('elmish_store');
423423
t.end()
@@ -451,13 +451,13 @@ test('elmish.add_attributes onclick=signal(action) events!', function (t) {
451451
});
452452

453453

454-
test.skip('subscriptions test using counter-reset-keyaboard ⌨️', function (t) {
454+
test.only('subscriptions test using counter-reset-keyaboard ⌨️', function (t) {
455455
const { view, update } = require('../examples/counter-reset/counter.js');
456456

457457
const root = document.getElementById(id);
458458
elmish.mount(0, update, view, id);
459459
// the "model" stored in localStorage should be 7 now:
460-
t.equal(JSON.parse(localStorage.getItem('elmish_store')), 0,
460+
t.equal(JSON.parse(localStorage.getItem('elmish_' + id)), 0,
461461
"elmish_store is 0 (as expected). initial state saved to localStorage.");
462462

463463
// trigger the [Enter] keyboard key to ADD the new todo:

Diff for: test/todo-app.test.js

-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ test('2. New Todo, should allow me to add todo items', function (t) {
222222
// trigger the [Enter] keyboard key to ADD the new todo:
223223
new_todo.dispatchEvent(new KeyboardEvent('keypress', {'keyCode': 13}));
224224
const items = document.querySelectorAll('.view');
225-
226225
t.equal(items.length, 1, "should allow me to add todo items");
227226
// check if the new todo was added to the DOM:
228227
const actual = document.getElementById('1').textContent;

Diff for: todo-list.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1497,7 +1497,7 @@ test('2. New Todo, should allow me to add todo items', function (t) {
14971497
t.equal('block', main_footer._values.display, "item added, show #footer");
14981498

14991499
elmish.empty(document.getElementById(id)); // clear DOM ready for next test
1500-
localStorage.removeItem('elmish_store');
1500+
localStorage.removeItem('elmish_store'); // clear "localStorage" for next test
15011501
t.end();
15021502
});
15031503
```
@@ -1510,7 +1510,7 @@ You should see the following output:
15101510

15111511
![test-failing](https://user-images.githubusercontent.com/194400/43929259-1880b41e-9c2c-11e8-9615-1372928c905d.png)
15121512

1513-
1513+
Reading: https://stackoverflow.com/questions/596481/is-it-possible-to-simulate-key-press-events-programmatically
15141514

15151515

15161516
<!--

0 commit comments

Comments
 (0)