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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 suite('util', function() {
6 test('getDescendants collects all children', function() {
7 var nodes = testTree(createFolder('0', [
8 createFolder('1', []),
9 createFolder(
10 '2',
11 [
12 createItem('3'),
13 createFolder(
14 '4',
15 [
16 createItem('6'),
17 createFolder('7', []),
18 ]),
19 createItem('5'),
20 ]),
21 ]));
22
23 var descendants = bookmarks.util.getDescendants(nodes, '1');
24 assertDeepEquals(['1'], normalizeSet(descendants));
25
26 descendants = bookmarks.util.getDescendants(nodes, '4');
27 assertDeepEquals(['4', '6', '7'], normalizeSet(descendants));
28
29 descendants = bookmarks.util.getDescendants(nodes, '2');
30 assertDeepEquals(['2', '3', '4', '5', '6', '7'], normalizeSet(descendants));
31
32 descendants = bookmarks.util.getDescendants(nodes, '42');
33 assertDeepEquals([], normalizeSet(descendants));
34 });
35
36 test('removeIdsFromMap', function() {
37 var map = {
38 '1': true,
39 '2': false,
40 '4': true,
41 };
42
43 var nodes = new Set([2, 3, 4]);
44
45 var newMap = bookmarks.util.removeIdsFromMap(map, nodes);
46
47 assertEquals(undefined, newMap['2']);
48 assertEquals(undefined, newMap['4']);
49 assertTrue(newMap['1']);
50
51 // Should not have changed the input map.
52 assertFalse(map['2']);
53 });
54
55 test('removeIdsFromSet', function() {
56 var set = new Set(['1', '3', '5']);
57 var toRemove = new Set(['1', '2', '3']);
58
59 var newSet = bookmarks.util.removeIdsFromSet(set, toRemove);
60 assertDeepEquals(['5'], normalizeSet(newSet));
61 });
62 });
OLDNEW
« 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