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

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

Issue 2752223004: MD Bookmarks: Remove deleted nodes from state tree (Closed)
Patch Set: Rebase 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 | « chrome/test/data/webui/md_bookmarks/reducers_test.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/util_test.js
diff --git a/chrome/test/data/webui/md_bookmarks/util_test.js b/chrome/test/data/webui/md_bookmarks/util_test.js
new file mode 100644
index 0000000000000000000000000000000000000000..0a05763fc2f0215c9ace6d45935a18887e0de7cd
--- /dev/null
+++ b/chrome/test/data/webui/md_bookmarks/util_test.js
@@ -0,0 +1,62 @@
+// 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('util', function() {
+ test('getDescendants collects all children', function() {
+ var nodes = testTree(createFolder('0', [
+ createFolder('1', []),
+ createFolder(
+ '2',
+ [
+ createItem('3'),
+ createFolder(
+ '4',
+ [
+ createItem('6'),
+ createFolder('7', []),
+ ]),
+ createItem('5'),
+ ]),
+ ]));
+
+ var descendants = bookmarks.util.getDescendants(nodes, '1');
+ assertDeepEquals(['1'], normalizeSet(descendants));
+
+ descendants = bookmarks.util.getDescendants(nodes, '4');
+ assertDeepEquals(['4', '6', '7'], normalizeSet(descendants));
+
+ descendants = bookmarks.util.getDescendants(nodes, '2');
+ assertDeepEquals(['2', '3', '4', '5', '6', '7'], normalizeSet(descendants));
+
+ descendants = bookmarks.util.getDescendants(nodes, '42');
+ assertDeepEquals([], normalizeSet(descendants));
+ });
+
+ test('removeIdsFromMap', function() {
+ var map = {
+ '1': true,
+ '2': false,
+ '4': true,
+ };
+
+ var nodes = new Set([2, 3, 4]);
+
+ var newMap = bookmarks.util.removeIdsFromMap(map, nodes);
+
+ assertEquals(undefined, newMap['2']);
+ assertEquals(undefined, newMap['4']);
+ assertTrue(newMap['1']);
+
+ // Should not have changed the input map.
+ assertFalse(map['2']);
+ });
+
+ test('removeIdsFromSet', function() {
+ var set = new Set(['1', '3', '5']);
+ var toRemove = new Set(['1', '2', '3']);
+
+ var newSet = bookmarks.util.removeIdsFromSet(set, toRemove);
+ assertDeepEquals(['5'], normalizeSet(newSet));
+ });
+});
« no previous file with comments | « chrome/test/data/webui/md_bookmarks/reducers_test.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698