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

Unified Diff: chrome/test/data/webui/md_bookmarks/reducers_test.js

Issue 2750463010: [MD Bookmarks] Handle bookmark moves. (Closed)
Patch Set: remove log Created 3 years, 9 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 | « chrome/browser/resources/md_bookmarks/reducers.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 02a8b93ffcdcdca6683c654bdb893270f83df62b..6e9c3dec69b29dcfc83b73d29710837b46e85e79 100644
--- a/chrome/test/data/webui/md_bookmarks/reducers_test.js
+++ b/chrome/test/data/webui/md_bookmarks/reducers_test.js
@@ -86,9 +86,14 @@ suite('closed folder state', function() {
var action;
setup(function() {
- nodes = testTree(createFolder('1', [
- createFolder('2', []),
- ]));
+ nodes = testTree(
+ createFolder(
+ '1',
+ [
+ createFolder('2', []),
+ createItem('3'),
+ ]),
+ createFolder('4', []));
state = {};
});
@@ -114,6 +119,24 @@ suite('closed folder state', function() {
bookmarks.ClosedFolderState.updateClosedFolders(state, action, nodes);
assertFalse(!!state['1']);
});
+
+ test('move nodes in a closed folder', function() {
+ // Moving bookmark items should not open folders.
+ state = {'1': true};
+ action = bookmarks.actions.moveBookmark('3', '1', 1, '1', 0);
+ state =
+ bookmarks.ClosedFolderState.updateClosedFolders(state, action, nodes);
+
+ assertTrue(state['1']);
+
+ // Moving folders should open their parents.
+ state = {'1': true, '2': true};
+ action = bookmarks.actions.moveBookmark('4', '2', 0, '0', 1);
+ state =
+ bookmarks.ClosedFolderState.updateClosedFolders(state, action, nodes);
+ assertFalse(!!state['1']);
+ assertFalse(!!state['2']);
+ });
});
suite('selected folder', function() {
@@ -200,6 +223,27 @@ suite('node state', function() {
// TODO(tsergeant): Deleted nodes should be removed from the nodes map
// entirely.
});
+
+ test('updates when a node is moved', function() {
+ // Move within the same folder backwards.
+ action = bookmarks.actions.moveBookmark('3', '1', 0, '1', 1);
+ state = bookmarks.NodeState.updateNodes(state, action);
+
+ assertDeepEquals(['3', '2', '4'], state['1'].children);
+
+ // Move within the same folder forwards.
+ action = bookmarks.actions.moveBookmark('3', '1', 2, '1', 0);
+ state = bookmarks.NodeState.updateNodes(state, action);
+
+ assertDeepEquals(['2', '4', '3'], state['1'].children);
+
+ // Move between different folders.
+ action = bookmarks.actions.moveBookmark('4', '5', 0, '1', 1);
+ state = bookmarks.NodeState.updateNodes(state, action);
+
+ assertDeepEquals(['2', '3'], state['1'].children);
+ assertDeepEquals(['4'], state['5'].children);
+ });
});
suite('search state', function() {
« no previous file with comments | « chrome/browser/resources/md_bookmarks/reducers.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698