| 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-router>', function() { | 5 suite('<bookmarks-router>', function() { |
| 6 var store; | 6 var store; |
| 7 var router; | 7 var router; |
| 8 | 8 |
| 9 function navigateTo(route) { | 9 function navigateTo(route) { |
| 10 window.history.replaceState({}, '', route); | 10 window.history.replaceState({}, '', route); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 /** | 68 /** |
| 69 * Reset the page state with a <bookmarks-app> and a clean Store, with the | 69 * Reset the page state with a <bookmarks-app> and a clean Store, with the |
| 70 * given |url| to trigger routing initialization code. | 70 * given |url| to trigger routing initialization code. |
| 71 */ | 71 */ |
| 72 function setupWithUrl(url) { | 72 function setupWithUrl(url) { |
| 73 PolymerTest.clearBody(); | 73 PolymerTest.clearBody(); |
| 74 bookmarks.Store.instance_ = undefined; | 74 bookmarks.Store.instance_ = undefined; |
| 75 window.history.replaceState({}, '', url); | 75 window.history.replaceState({}, '', url); |
| 76 | 76 |
| 77 chrome.bookmarks.getTree = function(callback) { | 77 chrome.bookmarks.getTree = function(callback) { |
| 78 console.log('getTree'); | |
| 79 console.log(window.location.href); | |
| 80 callback([ | 78 callback([ |
| 81 createFolder( | 79 createFolder( |
| 82 '0', | 80 '0', |
| 83 [ | 81 [ |
| 84 createFolder( | 82 createFolder( |
| 85 '1', | 83 '1', |
| 86 [ | 84 [ |
| 87 createFolder('11', []), | 85 createFolder('11', []), |
| 88 ]), | 86 ]), |
| 89 createFolder( | 87 createFolder( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 109 setupWithUrl('/?q=testQuery'); | 107 setupWithUrl('/?q=testQuery'); |
| 110 assertEquals('testQuery', lastQuery); | 108 assertEquals('testQuery', lastQuery); |
| 111 }); | 109 }); |
| 112 | 110 |
| 113 test('loading a folder URL selects that folder', function() { | 111 test('loading a folder URL selects that folder', function() { |
| 114 setupWithUrl('/?id=2'); | 112 setupWithUrl('/?id=2'); |
| 115 var state = bookmarks.Store.getInstance().data; | 113 var state = bookmarks.Store.getInstance().data; |
| 116 assertEquals('2', state.selectedFolder); | 114 assertEquals('2', state.selectedFolder); |
| 117 assertDeepEquals(['21'], bookmarks.util.getDisplayedList(state)); | 115 assertDeepEquals(['21'], bookmarks.util.getDisplayedList(state)); |
| 118 }); | 116 }); |
| 117 |
| 118 test('loading an invalid folder URL selects the Bookmarks Bar', function() { |
| 119 setupWithUrl('/?id=42'); |
| 120 var state = bookmarks.Store.getInstance().data; |
| 121 assertEquals('1', state.selectedFolder); |
| 122 return Promise.resolve().then(function() { |
| 123 assertEquals('chrome://bookmarks/?id=1', window.location.href); |
| 124 }); |
| 125 }); |
| 119 }); | 126 }); |
| OLD | NEW |