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

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, 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 unified diff | Download patch
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 function normalizeSet(set) {
24 return Array.from(set).sort();
25 }
calamity 2017/04/03 06:54:24 FYI, I needed this for another patch so I moved it
tsergeant 2017/04/04 04:42:28 Ack, picked up in the rebase
26
27 var descendants = bookmarks.util.getDescendants(nodes, '1');
28 assertDeepEquals(['1'], normalizeSet(descendants));
29
30 descendants = bookmarks.util.getDescendants(nodes, '4');
31 assertDeepEquals(['4', '6', '7'], normalizeSet(descendants));
32
33 descendants = bookmarks.util.getDescendants(nodes, '2');
34 assertDeepEquals(['2', '3', '4', '5', '6', '7'], normalizeSet(descendants));
35
36 descendants = bookmarks.util.getDescendants(nodes, '42');
37 assertDeepEquals([], normalizeSet(descendants));
38 });
39
40 test('removeNodesFromMap', function() {
41 var map = {
42 '1': true,
43 '2': false,
44 '4': true,
45 };
46
47 var nodes = new Set([2, 3, 4]);
48
49 var newMap = bookmarks.util.removeNodesFromMap(map, nodes);
50
51 assertEquals(undefined, newMap['2']);
52 assertEquals(undefined, newMap['4']);
53 assertTrue(newMap['1']);
54
55 // Should not have changed the input map.
56 assertFalse(map['2']);
57 });
58 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698