| 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('selection state', function() { | 5 suite('selection state', function() { | 
| 6   var state; | 6   var state; | 
| 7   var action; | 7   var action; | 
| 8 | 8 | 
| 9   function select(items, anchor, add) { | 9   function select(items, anchor, add) { | 
| 10     return { | 10     return { | 
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 216     assertEquals(undefined, state['4'].url); | 216     assertEquals(undefined, state['4'].url); | 
| 217 | 217 | 
| 218     // Cannot edit URL of a folder: | 218     // Cannot edit URL of a folder: | 
| 219     action = bookmarks.actions.editBookmark('4', {url: 'folder.com'}); | 219     action = bookmarks.actions.editBookmark('4', {url: 'folder.com'}); | 
| 220     state = bookmarks.NodeState.updateNodes(state, action); | 220     state = bookmarks.NodeState.updateNodes(state, action); | 
| 221 | 221 | 
| 222     assertEquals('folder', state['4'].title); | 222     assertEquals('folder', state['4'].title); | 
| 223     assertEquals(undefined, state['4'].url); | 223     assertEquals(undefined, state['4'].url); | 
| 224   }); | 224   }); | 
| 225 | 225 | 
|  | 226   test('updates when a node is created', function() { | 
|  | 227     // Create a folder. | 
|  | 228     var folder = { | 
|  | 229       id: '6', | 
|  | 230       parentId: '1', | 
|  | 231       index: 2, | 
|  | 232     }; | 
|  | 233     action = bookmarks.actions.createBookmark(folder.id, folder); | 
|  | 234     state = bookmarks.NodeState.updateNodes(state, action); | 
|  | 235 | 
|  | 236     assertEquals('1', state['6'].parentId); | 
|  | 237     assertDeepEquals([], state['6'].children); | 
|  | 238     assertDeepEquals(['2', '3', '6', '4'], state['1'].children); | 
|  | 239 | 
|  | 240     // Add a new item to that folder. | 
|  | 241     var item = { | 
|  | 242       id: '7', | 
|  | 243       parentId: '6', | 
|  | 244       index: 0, | 
|  | 245       url: 'https://www.example.com', | 
|  | 246     }; | 
|  | 247 | 
|  | 248     action = bookmarks.actions.createBookmark(item.id, item); | 
|  | 249     state = bookmarks.NodeState.updateNodes(state, action); | 
|  | 250 | 
|  | 251     assertEquals('6', state['7'].parentId); | 
|  | 252     assertEquals(undefined, state['7'].children); | 
|  | 253     assertDeepEquals(['7'], state['6'].children); | 
|  | 254   }); | 
|  | 255 | 
| 226   test('updates when a node is deleted', function() { | 256   test('updates when a node is deleted', function() { | 
| 227     action = bookmarks.actions.removeBookmark('3', '1', 1); | 257     action = bookmarks.actions.removeBookmark('3', '1', 1); | 
| 228     state = bookmarks.NodeState.updateNodes(state, action); | 258     state = bookmarks.NodeState.updateNodes(state, action); | 
| 229 | 259 | 
| 230     assertDeepEquals(['2', '4'], state['1'].children); | 260     assertDeepEquals(['2', '4'], state['1'].children); | 
| 231 | 261 | 
| 232     // TODO(tsergeant): Deleted nodes should be removed from the nodes map | 262     // TODO(tsergeant): Deleted nodes should be removed from the nodes map | 
| 233     // entirely. | 263     // entirely. | 
| 234   }); | 264   }); | 
| 235 | 265 | 
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 308     // Case 2: Clear search by selecting a new folder. | 338     // Case 2: Clear search by selecting a new folder. | 
| 309     action = bookmarks.actions.selectFolder('2'); | 339     action = bookmarks.actions.selectFolder('2'); | 
| 310     var selectedState = bookmarks.reduceAction(searchedState, action); | 340     var selectedState = bookmarks.reduceAction(searchedState, action); | 
| 311 | 341 | 
| 312     assertEquals('2', selectedState.selectedFolder); | 342     assertEquals('2', selectedState.selectedFolder); | 
| 313     assertDeepEquals(['3'], bookmarks.util.getDisplayedList(selectedState)); | 343     assertDeepEquals(['3'], bookmarks.util.getDisplayedList(selectedState)); | 
| 314     assertEquals('', selectedState.search.term); | 344     assertEquals('', selectedState.search.term); | 
| 315     assertDeepEquals([], selectedState.search.results); | 345     assertDeepEquals([], selectedState.search.results); | 
| 316   }); | 346   }); | 
| 317 }); | 347 }); | 
| OLD | NEW | 
|---|