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

Side by Side Diff: chrome/test/data/webui/md_bookmarks/sidebar_test.js

Issue 2823053003: [MD Bookmarks] Remove the bookmarks-sidebar element. (Closed)
Patch Set: rebase, address comments Created 3 years, 7 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/md_bookmarks_browsertest.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 2016 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('<bookmarks-sidebar>', function() {
6 var sidebar;
7 var store;
8
9 setup(function() {
10 store = new bookmarks.TestStore({
11 nodes: testTree(
12 createFolder(
13 '1',
14 [
15 createFolder(
16 '2',
17 [
18 createFolder('3', []),
19 createFolder('4', []),
20 ]),
21 createItem('5'),
22 ]),
23 createFolder('7', [])),
24 });
25 bookmarks.Store.instance_ = store;
26
27 sidebar = document.createElement('bookmarks-sidebar');
28 replaceBody(sidebar);
29 Polymer.dom.flush();
30 });
31
32 test('selecting and deselecting folders dispatches action', function() {
33 var rootFolders =
34 sidebar.$['folder-tree'].querySelectorAll('bookmarks-folder-node');
35 var firstGen = rootFolders[0].$['descendants'].querySelectorAll(
36 'bookmarks-folder-node');
37 var secondGen =
38 firstGen[0].$['descendants'].querySelectorAll('bookmarks-folder-node');
39
40 // Select nested folder.
41 firedId = '';
42 MockInteractions.tap(secondGen[0].$['folder-label']);
43 assertEquals('select-folder', store.lastAction.name);
44 assertEquals(secondGen[0].itemId, store.lastAction.id);
45
46 // Select folder in a separate subtree.
47 firedId = '';
48 MockInteractions.tap(rootFolders[1].$['folder-label']);
49 assertEquals('select-folder', store.lastAction.name);
50 assertEquals(rootFolders[1].itemId, store.lastAction.id);
51 });
52
53 test('depth calculation', function() {
54 var rootFolders =
55 sidebar.$['folder-tree'].querySelectorAll('bookmarks-folder-node');
56 var firstGen = rootFolders[0].$['descendants'].querySelectorAll(
57 'bookmarks-folder-node');
58 var secondGen =
59 firstGen[0].$['descendants'].querySelectorAll('bookmarks-folder-node');
60
61 Array.prototype.forEach.call(rootFolders, function(f) {
62 assertEquals(0, f.depth);
63 assertEquals('0', f.style.getPropertyValue('--node-depth'));
64 });
65 Array.prototype.forEach.call(firstGen, function(f) {
66 assertEquals(1, f.depth);
67 assertEquals('1', f.style.getPropertyValue('--node-depth'));
68 });
69 Array.prototype.forEach.call(secondGen, function(f) {
70 assertEquals(2, f.depth);
71 assertEquals('2', f.style.getPropertyValue('--node-depth'));
72 });
73 });
74
75 test('doesn\'t highlight selected folder while searching', function() {
76 var rootFolders =
77 sidebar.$['folder-tree'].querySelectorAll('bookmarks-folder-node');
78
79 store.data.selectedFolder = '1';
80 store.notifyObservers();
81
82 assertEquals('1', rootFolders['0'].itemId);
83 assertTrue(rootFolders['0'].isSelectedFolder_);
84
85 store.data.search = {
86 term: 'test',
87 inProgress: false,
88 results: ['3'],
89 };
90 store.notifyObservers();
91
92 assertFalse(rootFolders['0'].isSelectedFolder_);
93 });
94 });
OLDNEW
« no previous file with comments | « chrome/test/data/webui/md_bookmarks/md_bookmarks_browsertest.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698