OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 suite('<bookmarks-app>', function() { |
| 6 var app; |
| 7 var store; |
| 8 |
| 9 function resetStore() { |
| 10 store = new bookmarks.TestStore({}); |
| 11 store.acceptInitOnce(); |
| 12 bookmarks.Store.instance_ = store; |
| 13 |
| 14 chrome.bookmarks.getTree = function(fn) { |
| 15 fn([ |
| 16 createFolder( |
| 17 '0', |
| 18 [ |
| 19 createFolder( |
| 20 '1', |
| 21 [ |
| 22 createFolder('11', []), |
| 23 ]), |
| 24 ]), |
| 25 ]); |
| 26 }; |
| 27 } |
| 28 |
| 29 setup(function() { |
| 30 resetStore(); |
| 31 |
| 32 app = document.createElement('bookmarks-app'); |
| 33 replaceBody(app); |
| 34 }); |
| 35 |
| 36 teardown(function() { |
| 37 window.localStorage.clear(); |
| 38 }); |
| 39 |
| 40 test('write and load closed folder state', function() { |
| 41 var closedFolders = {'1': true}; |
| 42 store.data.closedFolders = closedFolders; |
| 43 store.notifyObservers(); |
| 44 |
| 45 // Ensure closed folders are written to local storage. |
| 46 assertDeepEquals( |
| 47 JSON.stringify(closedFolders), |
| 48 window.localStorage[LOCAL_STORAGE_CLOSED_FOLDERS_KEY]); |
| 49 |
| 50 resetStore(); |
| 51 app = document.createElement('bookmarks-app'); |
| 52 replaceBody(app); |
| 53 |
| 54 // Ensure closed folders are read from local storage. |
| 55 assertDeepEquals(closedFolders, store.data.closedFolders); |
| 56 }); |
| 57 }); |
OLD | NEW |