OLD | NEW |
(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 cr.define('bookmarks', function() { |
| 6 var TestStore = function(data) { |
| 7 this.data = Object.assign(bookmarks.util.createEmptyState(), data); |
| 8 this.lastAction_ = null; |
| 9 this.observers_ = []; |
| 10 }; |
| 11 |
| 12 TestStore.prototype = { |
| 13 addObserver: function(client) { |
| 14 this.observers_.push(client); |
| 15 }, |
| 16 |
| 17 removeObserver: function(client) {}, |
| 18 |
| 19 isInitialized: function() { |
| 20 return true; |
| 21 }, |
| 22 |
| 23 handleAction: function(action) { |
| 24 this.lastAction_ = action; |
| 25 }, |
| 26 |
| 27 get lastAction() { |
| 28 return this.lastAction_; |
| 29 }, |
| 30 |
| 31 notifyObservers: function() { |
| 32 // TODO(tsergeant): Revisit how state modifications work in UI tests. |
| 33 // We don't want tests to worry about modifying the whole state tree. |
| 34 // Instead, we could perform a deep clone in here to ensure that every |
| 35 // StoreClient is updated. |
| 36 this.observers_.forEach((client) => client.onStateChanged(this.data)); |
| 37 }, |
| 38 }; |
| 39 |
| 40 return { |
| 41 TestStore: TestStore, |
| 42 }; |
| 43 }); |
OLD | NEW |