Skip to content

Commit 533c3d1

Browse files
Persistence Test Proxy
1 parent e89bffa commit 533c3d1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/todo-app.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,3 +677,22 @@ test('9. Routing > should allow me to display active/completed/all items',
677677
localStorage.removeItem('todos-elmish_' + id);
678678
t.end();
679679
});
680+
test.only('8. Persistence > should persist its data', function (t) {
681+
elmish.empty(document.getElementById(id));
682+
const model = {
683+
todos: [
684+
{ id: 0, title: "Make something people want.", done: false }
685+
],
686+
hash: '#/'
687+
};
688+
// render the view and append it to the DOM inside the `test-app` node:
689+
elmish.mount(model, app.update, app.view, id, app.subscriptions);
690+
// confirm that the model is saved to localStorage
691+
console.log('localStorage', localStorage.getItem('todos-elmish_' + id));
692+
t.equal(localStorage.getItem('todos-elmish_' + id),
693+
JSON.stringify(model), "data is persisted to localStorage");
694+
695+
elmish.empty(document.getElementById(id)); // clear DOM ready for next test
696+
localStorage.removeItem('todos-elmish_' + id);
697+
t.end();
698+
});

0 commit comments

Comments
 (0)