| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 suite('<bookmarks-app>', function() { | 5 suite('<bookmarks-app>', function() { |
| 6 var app; | 6 var app; |
| 7 var store; | 7 var store; |
| 8 | 8 |
| 9 function resetStore() { | 9 function resetStore() { |
| 10 store = new bookmarks.TestStore({}); | 10 store = new bookmarks.TestStore({}); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 app = document.createElement('bookmarks-app'); | 32 app = document.createElement('bookmarks-app'); |
| 33 replaceBody(app); | 33 replaceBody(app); |
| 34 }); | 34 }); |
| 35 | 35 |
| 36 teardown(function() { | 36 teardown(function() { |
| 37 window.localStorage.clear(); | 37 window.localStorage.clear(); |
| 38 }); | 38 }); |
| 39 | 39 |
| 40 test('write and load closed folder state', function() { | 40 test('write and load closed folder state', function() { |
| 41 var closedFolders = {'1': true}; | 41 var closedFoldersList = ['1']; |
| 42 var closedFolders = new Set(closedFoldersList); |
| 42 store.data.closedFolders = closedFolders; | 43 store.data.closedFolders = closedFolders; |
| 43 store.notifyObservers(); | 44 store.notifyObservers(); |
| 44 | 45 |
| 45 // Ensure closed folders are written to local storage. | 46 // Ensure closed folders are written to local storage. |
| 46 assertDeepEquals( | 47 assertDeepEquals( |
| 47 JSON.stringify(closedFolders), | 48 JSON.stringify(Array.from(closedFolders)), |
| 48 window.localStorage[LOCAL_STORAGE_CLOSED_FOLDERS_KEY]); | 49 window.localStorage[LOCAL_STORAGE_CLOSED_FOLDERS_KEY]); |
| 49 | 50 |
| 50 resetStore(); | 51 resetStore(); |
| 51 app = document.createElement('bookmarks-app'); | 52 app = document.createElement('bookmarks-app'); |
| 52 replaceBody(app); | 53 replaceBody(app); |
| 53 | 54 |
| 54 // Ensure closed folders are read from local storage. | 55 // Ensure closed folders are read from local storage. |
| 55 assertDeepEquals(closedFolders, store.data.closedFolders); | 56 assertDeepEquals(closedFoldersList, normalizeSet(store.data.closedFolders)); |
| 56 }); | 57 }); |
| 57 }); | 58 }); |
| OLD | NEW |