Chromium Code Reviews| Index: chrome/test/data/webui/md_bookmarks/reducers_test.js |
| diff --git a/chrome/test/data/webui/md_bookmarks/reducers_test.js b/chrome/test/data/webui/md_bookmarks/reducers_test.js |
| index bffef5c0a938a3b8ccfc8ef05994c31aa46efc6d..01f79ac7f7c3880d91471252f1923f1a35fdc6b3 100644 |
| --- a/chrome/test/data/webui/md_bookmarks/reducers_test.js |
| +++ b/chrome/test/data/webui/md_bookmarks/reducers_test.js |
| @@ -2,6 +2,88 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +suite('selection state', function() { |
| + var initialState; |
| + |
| + function select(items, anchor, add) { |
| + return { |
| + name: 'select-items', |
| + add: add, |
| + anchor: anchor, |
| + items: items, |
| + }; |
| + } |
| + |
| + setup(function() { |
| + initialState = { |
| + anchor: null, |
| + count: 0, |
| + items: 1, |
|
calamity
2017/03/14 03:01:45
This is supposed to be an Object.
tsergeant
2017/03/14 05:42:02
Done.
|
| + }; |
| + }); |
| + |
| + test('can select an item', function() { |
| + var nextState; |
| + var action; |
| + |
| + action = select(['1'], '1', false); |
| + nextState = bookmarks.SelectionState.updateSelection(initialState, action); |
|
calamity
2017/03/14 03:01:45
nextState => state as in previous patch.
tsergeant
2017/03/14 05:42:02
Done.
|
| + |
| + assertDeepEquals({'1': true}, nextState.items); |
| + assertEquals('1', nextState.anchor); |
| + |
| + // Replace current selection. |
| + action = select(['2'], '2', false); |
| + nextState = bookmarks.SelectionState.updateSelection(nextState, action); |
| + assertDeepEquals({'2': true}, nextState.items); |
| + assertEquals('2', nextState.anchor); |
| + |
| + // Add to current selection. |
| + action = select(['3'], '3', true); |
| + nextState = bookmarks.SelectionState.updateSelection(nextState, action); |
| + assertDeepEquals({'2': true, '3': true}, nextState.items); |
| + assertEquals('3', nextState.anchor); |
| + }); |
| + |
| + test('can select multiple items', function() { |
| + var nextState; |
| + var action; |
| + |
| + action = select(['1', '2', '3'], '3', false); |
| + nextState = bookmarks.SelectionState.updateSelection(initialState, action); |
| + assertDeepEquals({'1': true, '2': true, '3': true}, nextState.items); |
| + |
| + action = select(['3', '4'], '4', true); |
| + nextState = bookmarks.SelectionState.updateSelection(nextState, action); |
| + assertDeepEquals( |
| + {'1': true, '2': true, '3': true, '4': true}, nextState.items); |
| + }); |
| + |
| + test('is cleared when selected folder changes', function() { |
| + var nextState; |
| + var action; |
| + |
| + action = select(['1', '2', '3'], '3', false); |
| + nextState = bookmarks.SelectionState.updateSelection(initialState, action); |
| + |
| + action = bookmarks.actions.selectFolder('2'); |
| + nextState = bookmarks.SelectionState.updateSelection(nextState, action); |
| + assertDeepEquals({}, nextState.items); |
| + }); |
| + |
| + test('is cleared when search finished', function() { |
| + var nextState; |
| + var action; |
| + |
| + action = select(['1', '2', '3'], '3', false); |
| + nextState = bookmarks.SelectionState.updateSelection(initialState, action); |
| + |
| + action = bookmarks.actions.setSearchResults(['2']); |
| + nextState = bookmarks.SelectionState.updateSelection(nextState, action); |
| + assertDeepEquals({}, nextState.items); |
| + }); |
| +}); |
| + |
| suite('closed folder state', function() { |
| var nodes; |
| var initialState; |