Skip to content

Commit 47821d0

Browse files
committed
Merge remote-tracking branch 'upstream/master' into fix-test-linting
2 parents 036f573 + 6ccb3db commit 47821d0

File tree

2 files changed

+13
-68
lines changed

2 files changed

+13
-68
lines changed

test/bindActionCreators.spec.js

Lines changed: 0 additions & 37 deletions
This file was deleted.

test/utils/bindActionCreators.spec.js

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,37 @@
11
import expect from 'expect';
22
import { bindActionCreators, createRedux } from '../../src';
3+
import * as helpers from '../_helpers';
34

4-
const fakeState = { foo: 'bar' };
5-
6-
function fakeStore(state = 0, action) {
7-
if (action.type) {
8-
return fakeState;
9-
}
10-
return state;
11-
}
12-
13-
const fakeActionCreators = {
14-
foo() {
15-
return { type: 'FOO' };
16-
},
17-
fooAsync() {
18-
return dispatch => {
19-
setImmediate(() => {
20-
dispatch({ type: 'FOO_ASYNC' });
21-
});
22-
};
23-
}
24-
};
5+
const { todoActions, todoStore } = helpers;
256

267
describe('Utils', () => {
278
describe('bindActionCreators', () => {
289

2910
let redux;
3011

3112
beforeEach(() => {
32-
redux = createRedux({ fakeStore });
13+
redux = createRedux({ todoStore });
3314
});
3415

3516
it('should bind given actions to the dispatcher', done => {
3617
let expectedCallCount = 2;
37-
// Let us subscribe to monitor the dispatched actions
18+
// just for monitoring the dispatched actions
3819
redux.subscribe(() => {
3920
expectedCallCount--;
40-
const state = redux.getState();
41-
42-
expect(state.fakeStore).toEqual(fakeState);
4321
if (expectedCallCount === 0) {
22+
const state = redux.getState();
23+
expect(state.todoStore).toEqual([
24+
{ id: 2, text: 'World' },
25+
{ id: 1, text: 'Hello' }
26+
]);
4427
done();
4528
}
4629
});
47-
const actions = bindActionCreators(fakeActionCreators, redux.dispatch);
48-
expect(Object.keys(actions))
49-
.toEqual(Object.keys(fakeActionCreators));
30+
const actions = bindActionCreators(todoActions, redux.dispatch);
31+
expect(Object.keys(actions)).toEqual(Object.keys(todoActions));
5032

51-
actions.foo();
52-
actions.fooAsync();
33+
actions.addTodo('Hello');
34+
actions.addTodoAsync('World');
5335
});
5436
});
5537
});

0 commit comments

Comments
 (0)