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

Unified Diff: chrome/test/data/webui/md_bookmarks/list_test.js

Issue 2704983002: MD Bookmarks: Proof-of-concept reimplementation of data storage/binding layer (Closed)
Patch Set: Add doc comments 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/webui/md_bookmarks/list_test.js
diff --git a/chrome/test/data/webui/md_bookmarks/list_test.js b/chrome/test/data/webui/md_bookmarks/list_test.js
index 9cf6755d34ae3a0730d208ba65f9f1f35388ec6d..61444b432e30ba5a5095223b089934b15215a4cd 100644
--- a/chrome/test/data/webui/md_bookmarks/list_test.js
+++ b/chrome/test/data/webui/md_bookmarks/list_test.js
@@ -4,28 +4,41 @@
suite('<bookmarks-list>', function() {
var list;
- var TEST_LIST =
- [createItem('0'), createItem('1'), createFolder('2', [], null)];
+ var store;
setup(function() {
+ store = new bookmarks.TestStore({
+ nodes: testTree(createFolder(
+ '0',
+ [
+ createItem('1'),
+ createFolder('3', [], null),
+ createItem('5'),
+ createItem('7'),
+ ])),
+ selectedFolder: '0',
+ });
+ bookmarks.Store.instance_ = store;
+
list = document.createElement('bookmarks-list');
replaceBody(list);
- list.displayedList = TEST_LIST;
+ Polymer.dom.flush();
});
test('folder menu item hides the url field', function() {
// Bookmark editor shows the url field.
- list.menuItem_ = TEST_LIST[0];
+ list.menuItem_ = store.data.nodes['1'];
assertFalse(list.$['url'].hidden);
// Folder editor hides the url field.
- list.menuItem_ = TEST_LIST[2];
+ list.menuItem_ = store.data.nodes['3'];
assertTrue(list.$['url'].hidden);
});
test('saving edit passes correct details to the update', function() {
// Saving bookmark edit.
- var menuItem = TEST_LIST[0];
+ var menuItem = store.data.nodes['1'];
+ // TODO(tsergeant): Avoid overwriting these functions directly.
chrome.bookmarks.update = function(id, edit) {
assertEquals(menuItem.id, id);
assertEquals(menuItem.url, edit.url);
@@ -36,7 +49,7 @@ suite('<bookmarks-list>', function() {
MockInteractions.tap(list.$.saveButton);
// Saving folder rename.
- menuItem = TEST_LIST[2];
+ menuItem = store.data.nodes['3'];
chrome.bookmarks.update = function(id, edit) {
assertEquals(menuItem.id, id);
assertEquals(menuItem.title, edit.title);
@@ -46,4 +59,42 @@ suite('<bookmarks-list>', function() {
list.$.editBookmark.showModal();
MockInteractions.tap(list.$.saveButton);
});
+
+ test('renders correct <bookmark-item> elements', function() {
+ var items = list.root.querySelectorAll('bookmarks-item');
+ var ids = Array.from(items).map((item) => item.itemId);
+
+ assertDeepEquals(['1', '3', '5', '7'], ids);
+ });
+
+ test('selects individual items', function() {
+ var items = list.root.querySelectorAll('bookmarks-item');
+
+ customClick(items[0]);
+ var expected = {
+ name: 'select-items',
+ add: false,
+ anchor: '1',
+ items: ['1'],
+ };
+ assertDeepEquals(expected, store.lastAction);
+
+ customClick(items[2], {ctrlKey: true});
+ expected.add = true;
+ expected.anchor = '5';
+ expected.items = ['5'];
+ assertDeepEquals(expected, store.lastAction);
+ });
+
+ test('shift-selects multiple items', function() {
+ var items = list.root.querySelectorAll('bookmarks-item');
+ store.data.selection.anchor = '1';
+
+ customClick(items[2], {shiftKey: true});
+
+ assertEquals('select-items', store.lastAction.name);
+ assertFalse(store.lastAction.add);
+ assertEquals('5', store.lastAction.anchor);
+ assertDeepEquals(['1', '3', '5'], store.lastAction.items);
+ });
});
« no previous file with comments | « chrome/test/data/webui/md_bookmarks/item_test.js ('k') | chrome/test/data/webui/md_bookmarks/md_bookmarks_browsertest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698