UNPKG

913 BJavaScriptView Raw
1/**
2 * Copyright 2014, Yahoo! Inc.
3 * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
4 */
5'use strict';
6
7var createMockActionContext = require('./createMockActionContext');
8function noop () {}
9
10function MockComponentContext (dispatcherContext) {
11 this.dispatcherContext = dispatcherContext;
12 this.executeActionCalls = [];
13 this.getStore = this.getStore.bind(this);
14 this.executeAction = this.executeAction.bind(this);
15}
16
17MockComponentContext.prototype.getStore = function (name) {
18 return this.dispatcherContext.getStore(name);
19};
20
21MockComponentContext.prototype.executeAction = function (action, payload) {
22 this.executeActionCalls.push({
23 action: action,
24 payload: payload
25 });
26 action(createMockActionContext({
27 dispatcherContext: this.dispatcherContext
28 }), payload, noop);
29};
30
31module.exports = MockComponentContext;