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

Side by Side Diff: chrome/test/data/webui/md_bookmarks/actions_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
« no previous file with comments | « no previous file | chrome/test/data/webui/md_bookmarks/list_test.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 /**
6 * @fileoverview Test suite for action creators that depend on the page state
7 * and/or have non-trivial logic.
8 */
9
10 suite('selectItem', function() {
11 var store;
12 var action;
13
14 setup(function() {
15 store = new bookmarks.TestStore({
16 nodes: testTree(createFolder(
17 '1',
18 [
19 createItem('2'),
20 createItem('8'),
21 createFolder('4', []),
22 createItem('6'),
23 ])),
24 selectedFolder: '1',
25 });
26 });
27
28 test('can select single item', function() {
29 action = bookmarks.actions.selectItem('2', true, false, store.data);
30 var expected = {
31 name: 'select-items',
32 items: ['2'],
33 add: true,
34 anchor: '2',
35 };
36 assertDeepEquals(expected, action);
37 });
38
39 test('can shift-select in regular list', function() {
40 store.data.selection.anchor = '2';
41 action = bookmarks.actions.selectItem('4', false, true, store.data);
42
43 assertDeepEquals(['2', '8', '4'], action.items);
44 assertDeepEquals('4', action.anchor);
45 });
46
47 test('can shift-select in search results', function() {
48 store.data.selectedFolder = null;
49 store.data.search = {
50 term: 'test',
51 results: ['1', '4', '8'],
52 inProgress: false,
53 };
54 store.data.selection.anchor = '8';
55
56 action = bookmarks.actions.selectItem('4', false, true, store.data);
57
58 assertDeepEquals(['4', '8'], action.items);
59 });
60
61 test('selects the item when the anchor is missing', function() {
62 // Anchor hasn't been set yet.
63 store.data.selection.anchor = null;
64
65 action = bookmarks.actions.selectItem('4', true, true, store.data);
66 assertEquals('4', action.anchor);
67 assertDeepEquals(['4'], action.items);
68
69 // Anchor set to an item which doesn't exist.
70 store.data.selection.anchor = '42';
71
72 action = bookmarks.actions.selectItem('8', true, true, store.data);
73 assertEquals('8', action.anchor);
74 assertDeepEquals(['8'], action.items);
75 });
76 });
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/webui/md_bookmarks/list_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698