Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: chrome/test/data/webui/md_bookmarks/store_test.js

Issue 2670473002: [MD Bookmarks] Implement adding folders and bookmarks from toolbar menu. (Closed)
Patch Set: Fix store to insert node instead of push and update tests. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 254
255 // Edit url and title updates idToNodeMap_ properly. 255 // Edit url and title updates idToNodeMap_ properly.
256 store.onBookmarkChanged_('2', { 256 store.onBookmarkChanged_('2', {
257 'title': 'test', 257 'title': 'test',
258 'url': 'http://www.google.com', 258 'url': 'http://www.google.com',
259 }); 259 });
260 assertEquals('test', store.idToNodeMap_['2'].title); 260 assertEquals('test', store.idToNodeMap_['2'].title);
261 assertEquals('http://www.google.com', store.idToNodeMap_['2'].url); 261 assertEquals('http://www.google.com', store.idToNodeMap_['2'].url);
262 }); 262 });
263 263
264 test('adding a folder updates tree with new node', function() {
265 chrome.bookmarks.create = function(info) {};
266
267 // Create a bookmark at end.
268 var parent = store.idToNodeMap_['8'];
269 var id = '9';
270 var config = {parentId: parent.id, index: parent.children.length};
271 store.onBookmarkCreated_(id, createItem(id, config));
272 var node = store.idToNodeMap_[id];
273 assertEquals(node, parent.children[config.index]);
274 assertEquals(parent.path + '.children.#' + config.index, node.path);
275 assertTrue('url' in node);
276
277 // Create a folder at the beginning.
278 var id = '10';
279 config = {parentId: parent.id, index: 0};
280 store.onBookmarkCreated_(id, createFolder(id, [], config));
281 node = store.idToNodeMap_[id];
282 assertEquals(node, parent.children[config.index]);
283 assertEquals(parent.path + '.children.#' + config.index, node.path);
284 assertFalse('url' in node);
285 });
286
264 test('folder gets updated after renaming', function() { 287 test('folder gets updated after renaming', function() {
265 store.onBookmarkChanged_('3', {'title': 'Main Folder'}); 288 store.onBookmarkChanged_('3', {'title': 'Main Folder'});
266 assertEquals('Main Folder', store.idToNodeMap_['3'].title); 289 assertEquals('Main Folder', store.idToNodeMap_['3'].title);
267 assertEquals(undefined, store.idToNodeMap_['3'].url); 290 assertEquals(undefined, store.idToNodeMap_['3'].url);
268 }); 291 });
269 292
270 ////////////////////////////////////////////////////////////////////////////// 293 //////////////////////////////////////////////////////////////////////////////
271 // search tests: 294 // search tests:
272 295
273 test('displayedList updates after searchTerm changes', function() { 296 test('displayedList updates after searchTerm changes', function() {
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 store.fire( 525 store.fire(
503 'select-item', {item: store.displayedList[2], add: true, range: false}); 526 'select-item', {item: store.displayedList[2], add: true, range: false});
504 store.fire( 527 store.fire(
505 'select-item', {item: store.displayedList[4], add: true, range: true}); 528 'select-item', {item: store.displayedList[4], add: true, range: true});
506 assertDeepEquals( 529 assertDeepEquals(
507 [true, false, true, true, true], 530 [true, false, true, true, true],
508 store.displayedList.map(i => i.isSelectedItem)); 531 store.displayedList.map(i => i.isSelectedItem));
509 assertEquals(2, store.anchorIndex_); 532 assertEquals(2, store.anchorIndex_);
510 }); 533 });
511 }); 534 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698