| 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 setup(function() { | 9 setup(function() { |
| 10 TEST_TREE = { | 10 TEST_TREE = createFolder('0', [ |
| 11 id: '0', | 11 createFolder( |
| 12 children: [ | 12 '1', |
| 13 { | 13 [ |
| 14 id: '1', | 14 createItem('2', {url: 'link2'}), |
| 15 children: [ | 15 createFolder('3', []), |
| 16 {id: '2', url: 'link2'}, | 16 ]), |
| 17 {id: '3', children: []} | 17 createItem('4', {url: 'link4'}), |
| 18 ] | 18 createItem('5', {url: 'link5'}), |
| 19 }, | 19 ]); |
| 20 {id: '4', url: 'link4'}, | |
| 21 {id: '5', url: 'link5'} | |
| 22 ] | |
| 23 }; | |
| 24 | 20 |
| 25 store = document.createElement('bookmarks-store'); | 21 store = document.createElement('bookmarks-store'); |
| 26 replaceBody(store); | 22 replaceBody(store); |
| 27 store.setupStore_(TEST_TREE); | 23 store.setupStore_(TEST_TREE); |
| 28 }); | 24 }); |
| 29 | 25 |
| 30 test('initNodes inserts nodes into idToNodeMap', function(){ | 26 test('initNodes inserts nodes into idToNodeMap', function(){ |
| 31 assertEquals(TEST_TREE, store.idToNodeMap_['0']); | 27 assertEquals(TEST_TREE, store.idToNodeMap_['0']); |
| 32 assertEquals(TEST_TREE.children[0], store.idToNodeMap_['1']); | 28 assertEquals(TEST_TREE.children[0], store.idToNodeMap_['1']); |
| 33 assertEquals(TEST_TREE.children[0].children[0], store.idToNodeMap_['2']); | 29 assertEquals(TEST_TREE.children[0].children[0], store.idToNodeMap_['2']); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 assertTrue(store.idToNodeMap_['1'].isSelected); | 161 assertTrue(store.idToNodeMap_['1'].isSelected); |
| 166 assertEquals('1', store.selectedId); | 162 assertEquals('1', store.selectedId); |
| 167 | 163 |
| 168 // A folder with selected folder in it gets removed. | 164 // A folder with selected folder in it gets removed. |
| 169 store.selectedId = '3'; | 165 store.selectedId = '3'; |
| 170 store.onBookmarkRemoved_('1', {parentId:'0', index:'0'}); | 166 store.onBookmarkRemoved_('1', {parentId:'0', index:'0'}); |
| 171 assertTrue(store.idToNodeMap_['0'].isSelected); | 167 assertTrue(store.idToNodeMap_['0'].isSelected); |
| 172 assertEquals('0', store.selectedId); | 168 assertEquals('0', store.selectedId); |
| 173 }); | 169 }); |
| 174 }); | 170 }); |
| OLD | NEW |