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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 assertEquals(undefined, state['4'].url); | 207 assertEquals(undefined, state['4'].url); |
208 | 208 |
209 // Cannot edit URL of a folder: | 209 // Cannot edit URL of a folder: |
210 action = bookmarks.actions.editBookmark('4', {url: 'folder.com'}); | 210 action = bookmarks.actions.editBookmark('4', {url: 'folder.com'}); |
211 state = bookmarks.NodeState.updateNodes(state, action); | 211 state = bookmarks.NodeState.updateNodes(state, action); |
212 | 212 |
213 assertEquals('folder', state['4'].title); | 213 assertEquals('folder', state['4'].title); |
214 assertEquals(undefined, state['4'].url); | 214 assertEquals(undefined, state['4'].url); |
215 }); | 215 }); |
216 | 216 |
217 test('updates when a node is created', function() { | |
218 var node = { | |
219 id: '6', | |
220 parentId: '1', | |
221 index: 2, | |
222 }; | |
223 action = bookmarks.actions.createBookmark(node.id, node); | |
224 state = bookmarks.NodeState.updateNodes(state, action); | |
225 | |
226 assertEquals('1', state['6'].parentId); | |
227 assertDeepEquals([], state['6'].children); | |
228 assertDeepEquals(['2', '3', '6', '4'], state['1'].children); | |
229 }); | |
calamity
2017/04/04 08:14:51
Can we also get a test for a folder creation?
tsergeant
2017/04/05 02:45:58
That one is a test for folder creation, but I've m
| |
230 | |
217 test('updates when a node is deleted', function() { | 231 test('updates when a node is deleted', function() { |
218 action = bookmarks.actions.removeBookmark('3', '1', 1); | 232 action = bookmarks.actions.removeBookmark('3', '1', 1); |
219 state = bookmarks.NodeState.updateNodes(state, action); | 233 state = bookmarks.NodeState.updateNodes(state, action); |
220 | 234 |
221 assertDeepEquals(['2', '4'], state['1'].children); | 235 assertDeepEquals(['2', '4'], state['1'].children); |
222 | 236 |
223 // TODO(tsergeant): Deleted nodes should be removed from the nodes map | 237 // TODO(tsergeant): Deleted nodes should be removed from the nodes map |
224 // entirely. | 238 // entirely. |
225 }); | 239 }); |
226 | 240 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
299 // Case 2: Clear search by selecting a new folder. | 313 // Case 2: Clear search by selecting a new folder. |
300 action = bookmarks.actions.selectFolder('2'); | 314 action = bookmarks.actions.selectFolder('2'); |
301 var selectedState = bookmarks.reduceAction(searchedState, action); | 315 var selectedState = bookmarks.reduceAction(searchedState, action); |
302 | 316 |
303 assertEquals('2', selectedState.selectedFolder); | 317 assertEquals('2', selectedState.selectedFolder); |
304 assertDeepEquals(['3'], bookmarks.util.getDisplayedList(selectedState)); | 318 assertDeepEquals(['3'], bookmarks.util.getDisplayedList(selectedState)); |
305 assertEquals('', selectedState.search.term); | 319 assertEquals('', selectedState.search.term); |
306 assertDeepEquals([], selectedState.search.results); | 320 assertDeepEquals([], selectedState.search.results); |
307 }); | 321 }); |
308 }); | 322 }); |
OLD | NEW |