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

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

Issue 2808333004: MD Bookmarks: Improve test coverage for Actions and Routing (Closed)
Patch Set: Remove .only Created 3 years, 8 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({
(...skipping 14 matching lines...) Expand all
25 Polymer.dom.flush(); 25 Polymer.dom.flush();
26 }); 26 });
27 27
28 test('renders correct <bookmark-item> elements', function() { 28 test('renders correct <bookmark-item> elements', function() {
29 var items = list.root.querySelectorAll('bookmarks-item'); 29 var items = list.root.querySelectorAll('bookmarks-item');
30 var ids = Array.from(items).map((item) => item.itemId); 30 var ids = Array.from(items).map((item) => item.itemId);
31 31
32 assertDeepEquals(['1', '3', '5', '7'], ids); 32 assertDeepEquals(['1', '3', '5', '7'], ids);
33 }); 33 });
34 34
35 test('selects individual items', function() {
36 var items = list.root.querySelectorAll('bookmarks-item');
37
38 customClick(items[0]);
39 var expected = {
40 name: 'select-items',
41 add: false,
42 anchor: '1',
43 items: ['1'],
44 };
45 assertDeepEquals(expected, store.lastAction);
46
47 customClick(items[2], {ctrlKey: true});
48 expected.add = true;
49 expected.anchor = '5';
50 expected.items = ['5'];
51 assertDeepEquals(expected, store.lastAction);
52 });
53
54 test('shift-selects multiple items', function() { 35 test('shift-selects multiple items', function() {
55 var items = list.root.querySelectorAll('bookmarks-item'); 36 var items = list.root.querySelectorAll('bookmarks-item');
56 store.data.selection.anchor = '1';
57 37
58 customClick(items[2], {shiftKey: true}); 38 customClick(items[0]);
59 39
60 assertEquals('select-items', store.lastAction.name); 40 assertEquals('select-items', store.lastAction.name);
61 assertFalse(store.lastAction.add); 41 assertFalse(store.lastAction.add);
42 assertEquals('1', store.lastAction.anchor);
43 assertDeepEquals(['1'], store.lastAction.items);
44
45 store.data.selection.anchor = '1';
46 customClick(items[2], {shiftKey: true, ctrlKey: true});
47
48 assertEquals('select-items', store.lastAction.name);
49 assertTrue(store.lastAction.add);
62 assertEquals('5', store.lastAction.anchor); 50 assertEquals('5', store.lastAction.anchor);
63 assertDeepEquals(['1', '3', '5'], store.lastAction.items); 51 assertDeepEquals(['1', '3', '5'], store.lastAction.items);
64 }); 52 });
65 53
66 test('selects the item when the anchor is missing', function() {
67 var items = list.root.querySelectorAll('bookmarks-item');
68 // Anchor hasn't been set yet:
69 store.data.selection.anchor = null;
70
71 customClick(items[0], {shiftKey: true});
72 assertEquals('1', store.lastAction.anchor);
73 assertDeepEquals(['1'], store.lastAction.items);
74
75 // Anchor item doesn't exist:
76 store.data.selection.anchor = '42';
77
78 customClick(items[1], {shiftKey: true});
79
80 assertEquals('3', store.lastAction.anchor);
81 assertDeepEquals(['3'], store.lastAction.items);
82 });
83
84 test('deselects items on click outside of card', function() { 54 test('deselects items on click outside of card', function() {
85 customClick(list); 55 customClick(list);
86 assertEquals('deselect-items', store.lastAction.name); 56 assertEquals('deselect-items', store.lastAction.name);
87 }); 57 });
88 }); 58 });
OLDNEW
« no previous file with comments | « chrome/test/data/webui/md_bookmarks/actions_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