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

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

Issue 2946203002: MD Bookmarks: Batch updates to the UI when processing deletes and moves (Closed)
Patch Set: Batch in API listener Created 3 years, 5 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/store_client_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
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 suite('bookmarks.Store', function() {
6 var store;
7
8 setup(function() {
9 store = new bookmarks.TestStore({
10 nodes: testTree(createFolder(
11 '1',
12 [
13 createItem('11'),
14 createItem('12'),
15 createItem('13'),
16 ])),
17 });
18 store.setReducersEnabled(true);
19 store.replaceSingleton();
20 });
21
22 test('batch mode disables updates', function() {
23 var lastStateChange = null;
24 var observer = {
25 onStateChanged: function(state) {
26 lastStateChange = state;
27 },
28 };
29
30 store.addObserver(observer);
31 store.beginBatchUpdate();
32
33 store.dispatch(
34 bookmarks.actions.removeBookmark('11', '1', 0, store.data.nodes));
35 assertEquals(null, lastStateChange);
36 store.dispatch(
37 bookmarks.actions.removeBookmark('12', '1', 0, store.data.nodes));
38 assertEquals(null, lastStateChange);
39
40 store.endBatchUpdate();
41 assertDeepEquals(['13'], lastStateChange.nodes['1'].children);
42 });
43 });
44
5 suite('bookmarks.StoreClient', function() { 45 suite('bookmarks.StoreClient', function() {
6 var store; 46 var store;
7 var client; 47 var client;
8 48
9 function update(newState) { 49 function update(newState) {
10 store.notifyObservers_(newState); 50 store.notifyObservers_(newState);
11 Polymer.dom.flush(); 51 Polymer.dom.flush();
12 } 52 }
13 53
14 function getRenderedItems() { 54 function getRenderedItems() {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 assertDeepEquals(newItems, getRenderedItems()); 125 assertDeepEquals(newItems, getRenderedItems());
86 }); 126 });
87 127
88 test('ignores changes to other subtrees', function() { 128 test('ignores changes to other subtrees', function() {
89 var newState = Object.assign({}, store.data, {count: 2}); 129 var newState = Object.assign({}, store.data, {count: 2});
90 update(newState); 130 update(newState);
91 131
92 assertFalse(client.hasChanged); 132 assertFalse(client.hasChanged);
93 }); 133 });
94 }); 134 });
OLDNEW
« no previous file with comments | « chrome/test/data/webui/md_bookmarks/store_client_test.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698