Chromium Code Reviews| Index: chrome/test/data/webui/md_bookmarks/command_manager_test.js |
| diff --git a/chrome/test/data/webui/md_bookmarks/command_manager_test.js b/chrome/test/data/webui/md_bookmarks/command_manager_test.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..197361829796a9ad0f13e7cc0704edc903786ead |
| --- /dev/null |
| +++ b/chrome/test/data/webui/md_bookmarks/command_manager_test.js |
| @@ -0,0 +1,47 @@ |
| +// 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. |
| + |
| +suite('<bookmarks-command-manager>', function() { |
| + var commandManager; |
| + var store; |
| + |
| + setup(function() { |
| + store = new bookmarks.TestStore({ |
| + nodes: testTree(createFolder( |
| + '1', |
| + [ |
| + createFolder('11', []), |
| + createFolder('12', []), |
| + createItem('13'), |
| + ])), |
| + }); |
| + bookmarks.Store.instance_ = store; |
| + |
| + commandManager = document.createElement('bookmarks-command-manager'); |
| + replaceBody(commandManager); |
| + }); |
| + |
| + test('canCopy only single URLs', function() { |
|
calamity
2017/04/24 05:20:35
nit: single URL items
tsergeant
2017/04/24 07:28:23
Done.
|
| + assertFalse(commandManager.canCopy(new Set(['11']))); |
| + assertFalse(commandManager.canCopy(new Set(['11', '13']))); |
| + assertTrue(commandManager.canCopy(new Set(['13']))); |
| + }); |
| + |
| + test('context menu hides invalid commands', function() { |
| + store.data.selection.items = new Set(['11', '13']); |
| + store.notifyObservers(); |
| + |
| + commandManager.openCommandMenuAtPosition(0, 0); |
| + var commandHidden = {}; |
| + commandManager.root.querySelectorAll('.dropdown-item').forEach(element => { |
| + commandHidden[element.getAttribute('command')] = element.hidden; |
| + }); |
| + |
| + // With a folder and an item selected, the only available context menu item |
| + // is 'Delete'. |
| + assertTrue(commandHidden['edit']); |
| + assertTrue(commandHidden['copy']); |
| + assertFalse(commandHidden['delete']); |
| + }); |
| +}); |