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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/md_bookmarks/actions_test.js
diff --git a/chrome/test/data/webui/md_bookmarks/actions_test.js b/chrome/test/data/webui/md_bookmarks/actions_test.js
new file mode 100644
index 0000000000000000000000000000000000000000..ccb8707e2f4e0184fb0db8dbd01e0b1492703c18
--- /dev/null
+++ b/chrome/test/data/webui/md_bookmarks/actions_test.js
@@ -0,0 +1,76 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @fileoverview Test suite for action creators that depend on the page state
+ * and/or have non-trivial logic.
+ */
+
+suite('selectItem', function() {
+ var store;
+ var action;
+
+ setup(function() {
+ store = new bookmarks.TestStore({
+ nodes: testTree(createFolder(
+ '1',
+ [
+ createItem('2'),
+ createItem('8'),
+ createFolder('4', []),
+ createItem('6'),
+ ])),
+ selectedFolder: '1',
+ });
+ });
+
+ test('can select single item', function() {
+ action = bookmarks.actions.selectItem('2', true, false, store.data);
+ var expected = {
+ name: 'select-items',
+ items: ['2'],
+ add: true,
+ anchor: '2',
+ };
+ assertDeepEquals(expected, action);
+ });
+
+ test('can shift-select in regular list', function() {
+ store.data.selection.anchor = '2';
+ action = bookmarks.actions.selectItem('4', false, true, store.data);
+
+ assertDeepEquals(['2', '8', '4'], action.items);
+ assertDeepEquals('4', action.anchor);
+ });
+
+ test('can shift-select in search results', function() {
+ store.data.selectedFolder = null;
+ store.data.search = {
+ term: 'test',
+ results: ['1', '4', '8'],
+ inProgress: false,
+ };
+ store.data.selection.anchor = '8';
+
+ action = bookmarks.actions.selectItem('4', false, true, store.data);
+
+ assertDeepEquals(['4', '8'], action.items);
+ });
+
+ test('selects the item when the anchor is missing', function() {
+ // Anchor hasn't been set yet.
+ store.data.selection.anchor = null;
+
+ action = bookmarks.actions.selectItem('4', true, true, store.data);
+ assertEquals('4', action.anchor);
+ assertDeepEquals(['4'], action.items);
+
+ // Anchor set to an item which doesn't exist.
+ store.data.selection.anchor = '42';
+
+ action = bookmarks.actions.selectItem('8', true, true, store.data);
+ assertEquals('8', action.anchor);
+ assertDeepEquals(['8'], action.items);
+ });
+});
« 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