| Index: chrome/test/data/webui/md_bookmarks/test_store.js
|
| diff --git a/chrome/test/data/webui/md_bookmarks/test_store.js b/chrome/test/data/webui/md_bookmarks/test_store.js
|
| index 10fab150dd8ad5be18aa6e94106125c4a714deb4..cdf2571c9ac8bb4ab4b1fe062cc0251b01c27c22 100644
|
| --- a/chrome/test/data/webui/md_bookmarks/test_store.js
|
| +++ b/chrome/test/data/webui/md_bookmarks/test_store.js
|
| @@ -12,6 +12,8 @@ suiteSetup(function() {
|
| this.lastAction_ = null;
|
| this.acceptInit_ = false;
|
| this.enableReducers_ = false;
|
| + /** @type {!Map<string, !PromiseResolver>} */
|
| + this.resolverMap_ = new Map();
|
| };
|
|
|
| TestStore.prototype = {
|
| @@ -54,6 +56,8 @@ suiteSetup(function() {
|
| this.lastAction_ = action;
|
| if (this.enableReducers_)
|
| bookmarks.Store.prototype.reduce_.call(this, action);
|
| + if (this.resolverMap_.has(action.name))
|
| + this.resolverMap_.get(action.name).resolve(action);
|
| },
|
|
|
| /**
|
| @@ -71,6 +75,32 @@ suiteSetup(function() {
|
| this.acceptInit_ = true;
|
| this.initialized_ = false;
|
| },
|
| +
|
| + /**
|
| + * Track actions called |name|, allowing that type of action to be waited
|
| + * for with `waitForAction`.
|
| + * @param {string} name
|
| + */
|
| + expectAction: function(name) {
|
| + this.resolverMap_.set(name, new PromiseResolver());
|
| + },
|
| +
|
| + /**
|
| + * Returns a Promise that will resolve when an action called |name| is
|
| + * dispatched. The promise must be prepared by calling
|
| + * `expectAction(name)` before the action is dispatched.
|
| + * @param {string} name
|
| + * @return {!Promise<!Action>}
|
| + */
|
| + waitForAction: function(name) {
|
| + assertTrue(
|
| + this.resolverMap_.has(name),
|
| + 'Must call expectAction before each call to waitForAction');
|
| + return this.resolverMap_.get(name).promise.then((action) => {
|
| + this.resolverMap_.delete(name);
|
| + return action;
|
| + });
|
| + },
|
| };
|
|
|
| return {
|
|
|