1 |
|
2 |
|
3 |
|
4 |
|
5 | 'use strict';
|
6 |
|
7 | var createMockActionContext = require('./createMockActionContext');
|
8 | function noop () {}
|
9 |
|
10 | function 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 |
|
17 | MockComponentContext.prototype.getStore = function (name) {
|
18 | return this.dispatcherContext.getStore(name);
|
19 | };
|
20 |
|
21 | MockComponentContext.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 |
|
31 | module.exports = MockComponentContext;
|