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

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

Issue 2742583003: MD Bookmarks: Extract bookmark editing into a <bookmark-edit-dialog> element (Closed)
Patch Set: Rename event handlers Created 3 years, 9 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-list>', function() { 5 suite('<bookmarks-list>', function() {
6 var list; 6 var list;
7 var store; 7 var store;
8 8
9 setup(function() { 9 setup(function() {
10 store = new bookmarks.TestStore({ 10 store = new bookmarks.TestStore({
11 nodes: testTree(createFolder( 11 nodes: testTree(createFolder(
12 '0', 12 '0',
13 [ 13 [
14 createItem('1'), 14 createItem('1'),
15 createFolder('3', []), 15 createFolder('3', []),
16 createItem('5'), 16 createItem('5'),
17 createItem('7'), 17 createItem('7'),
18 ])), 18 ])),
19 selectedFolder: '0', 19 selectedFolder: '0',
20 }); 20 });
21 bookmarks.Store.instance_ = store; 21 bookmarks.Store.instance_ = store;
22 22
23 list = document.createElement('bookmarks-list'); 23 list = document.createElement('bookmarks-list');
24 replaceBody(list); 24 replaceBody(list);
25 Polymer.dom.flush(); 25 Polymer.dom.flush();
26 }); 26 });
27 27
28 test('folder menu item hides the url field', function() {
29 // Bookmark editor shows the url field.
30 list.menuItem_ = store.data.nodes['1'];
31 assertFalse(list.$['url'].hidden);
32
33 // Folder editor hides the url field.
34 list.menuItem_ = store.data.nodes['3'];
35 assertTrue(list.$['url'].hidden);
36 });
37
38 test('saving edit passes correct details to the update', function() {
39 // Saving bookmark edit.
40 var menuItem = store.data.nodes['1'];
41 chrome.bookmarks.update = function(id, edit) {
42 assertEquals(menuItem.id, id);
43 assertEquals(menuItem.url, edit.url);
44 assertEquals(menuItem.title, edit.title);
45 };
46 list.menuItem_ = menuItem;
47 list.$.editBookmark.showModal();
48 MockInteractions.tap(list.$.saveButton);
49
50 // Saving folder rename.
51 menuItem = store.data.nodes['3'];
52 chrome.bookmarks.update = function(id, edit) {
53 assertEquals(menuItem.id, id);
54 assertEquals(menuItem.title, edit.title);
55 assertEquals(undefined, edit.url);
56 };
57 list.menuItem_ = menuItem;
58 list.$.editBookmark.showModal();
59 MockInteractions.tap(list.$.saveButton);
60 });
61
62 test('renders correct <bookmark-item> elements', function() { 28 test('renders correct <bookmark-item> elements', function() {
63 var items = list.root.querySelectorAll('bookmarks-item'); 29 var items = list.root.querySelectorAll('bookmarks-item');
64 var ids = Array.from(items).map((item) => item.itemId); 30 var ids = Array.from(items).map((item) => item.itemId);
65 31
66 assertDeepEquals(['1', '3', '5', '7'], ids); 32 assertDeepEquals(['1', '3', '5', '7'], ids);
67 }); 33 });
68 34
69 test('selects individual items', function() { 35 test('selects individual items', function() {
70 var items = list.root.querySelectorAll('bookmarks-item'); 36 var items = list.root.querySelectorAll('bookmarks-item');
71 37
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 74
109 // Anchor item doesn't exist: 75 // Anchor item doesn't exist:
110 store.data.selection.anchor = '42'; 76 store.data.selection.anchor = '42';
111 77
112 customClick(items[1], {shiftKey: true}); 78 customClick(items[1], {shiftKey: true});
113 79
114 assertEquals('3', store.lastAction.anchor); 80 assertEquals('3', store.lastAction.anchor);
115 assertDeepEquals(['3'], store.lastAction.items); 81 assertDeepEquals(['3'], store.lastAction.items);
116 }); 82 });
117 }); 83 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698