| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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-store>', function() { | 5 suite('<bookmarks-store>', function() { |
| 6 var store; | 6 var store; |
| 7 var TEST_TREE; | 7 var TEST_TREE; |
| 8 | 8 |
| 9 function replaceStore() { | 9 function replaceStore() { |
| 10 store = document.createElement('bookmarks-store'); | 10 store = document.createElement('bookmarks-store'); |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 | 244 |
| 245 // Edit url and title updates idToNodeMap_ properly. | 245 // Edit url and title updates idToNodeMap_ properly. |
| 246 store.onBookmarkChanged_('2', { | 246 store.onBookmarkChanged_('2', { |
| 247 'title': 'test', | 247 'title': 'test', |
| 248 'url': 'http://www.google.com', | 248 'url': 'http://www.google.com', |
| 249 }); | 249 }); |
| 250 assertEquals('test', store.idToNodeMap_['2'].title); | 250 assertEquals('test', store.idToNodeMap_['2'].title); |
| 251 assertEquals('http://www.google.com', store.idToNodeMap_['2'].url); | 251 assertEquals('http://www.google.com', store.idToNodeMap_['2'].url); |
| 252 }); | 252 }); |
| 253 | 253 |
| 254 test('adding a folder updates tree with new node', function() { |
| 255 chrome.bookmarks.create = function(info) {}; |
| 256 |
| 257 // Create a bookmark. |
| 258 var parent = store.idToNodeMap_['8']; |
| 259 var id = '9'; |
| 260 store.onBookmarkCreated_(id, createItem(id, {parentId: parent.id})); |
| 261 var lastIndex = parent.children.length - 1; |
| 262 var node = store.idToNodeMap_[id]; |
| 263 assertEquals(node, parent.children[lastIndex]); |
| 264 assertEquals(parent.path + '.children.#' + lastIndex, node.path); |
| 265 assertTrue('url' in node); |
| 266 |
| 267 // Create a folder. |
| 268 var id = '10'; |
| 269 store.onBookmarkCreated_(id, createFolder(id, [], {parentId: parent.id})); |
| 270 lastIndex = parent.children.length - 1; |
| 271 node = store.idToNodeMap_[id]; |
| 272 assertEquals(node, parent.children[lastIndex]); |
| 273 assertEquals(parent.path + '.children.#' + lastIndex, node.path); |
| 274 assertFalse('url' in node); |
| 275 }); |
| 276 |
| 254 ////////////////////////////////////////////////////////////////////////////// | 277 ////////////////////////////////////////////////////////////////////////////// |
| 255 // search tests: | 278 // search tests: |
| 256 | 279 |
| 257 test('displayedList updates after searchTerm changes', function() { | 280 test('displayedList updates after searchTerm changes', function() { |
| 258 var SEARCH_RESULTS = [ | 281 var SEARCH_RESULTS = [ |
| 259 createItem('1', {title: 'cat'}), | 282 createItem('1', {title: 'cat'}), |
| 260 createItem('2', {title: 'apple'}), | 283 createItem('2', {title: 'apple'}), |
| 261 createItem('3', {title: 'paris'}), | 284 createItem('3', {title: 'paris'}), |
| 262 ]; | 285 ]; |
| 263 overrideBookmarksSearch(SEARCH_RESULTS); | 286 overrideBookmarksSearch(SEARCH_RESULTS); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 store.fire( | 509 store.fire( |
| 487 'select-item', {item: store.displayedList[2], add: true, range: false}); | 510 'select-item', {item: store.displayedList[2], add: true, range: false}); |
| 488 store.fire( | 511 store.fire( |
| 489 'select-item', {item: store.displayedList[4], add: true, range: true}); | 512 'select-item', {item: store.displayedList[4], add: true, range: true}); |
| 490 assertDeepEquals( | 513 assertDeepEquals( |
| 491 [true, false, true, true, true], | 514 [true, false, true, true, true], |
| 492 store.displayedList.map(i => i.isSelectedItem)); | 515 store.displayedList.map(i => i.isSelectedItem)); |
| 493 assertEquals(2, store.anchorIndex_); | 516 assertEquals(2, store.anchorIndex_); |
| 494 }); | 517 }); |
| 495 }); | 518 }); |
| OLD | NEW |