Skip to content

Commit 6aa4431

Browse files
committed
Merge pull request reduxjs#72 from emmenko/fix-tests
Adjust tests after API changes
2 parents 4fa1f51 + e460e6a commit 6aa4431

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/Redux.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@ export default class Redux {
4040
}
4141

4242
subscribe(listener) {
43-
this.listeners.push(listener);
43+
const { listeners } = this;
44+
listeners.push(listener);
4445

4546
return function unsubscribe () {
46-
const index = this.listeners.indexOf(listener);
47-
this.listeners.splice(index, 1);
47+
const index = listeners.indexOf(listener);
48+
listeners.splice(index, 1);
4849
};
4950
}
5051
}

test/createDispatcher.spec.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import expect from 'expect';
22
import { createDispatcher, composeStores } from '../src';
3+
import thunkMiddleware from '../src/middleware/thunk';
34

45
const fakeState = { foo: 'bar' };
56
const fakeAction = { type: 'FOO', foo: 'bar' };
@@ -33,7 +34,9 @@ describe('createDispatcher', () => {
3334

3435
it('should handle sync and async dispatches', done => {
3536
const spy = expect.createSpy(() => {});
36-
const dispatcher = createDispatcher(composeStores({ fakeStore }));
37+
const dispatcher = createDispatcher(
38+
composeStores({ fakeStore }),
39+
getState => [thunkMiddleware(getState)]);
3740
expect(dispatcher).toBeA('function');
3841

3942
const dispatchFn = dispatcher(fakeState, spy);

test/exports.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ describe('Redux', () => {
55

66
it('should export necessary components', () => {
77
const imports = Object.keys(redux);
8-
expect(imports.length).toBe(8);
8+
expect(imports.length).toBe(9);
99

1010
expect(imports).toContain('createRedux');
1111
expect(imports).toContain('createDispatcher');
@@ -16,6 +16,7 @@ describe('Redux', () => {
1616
expect(imports).toContain('provide');
1717
expect(imports).toContain('connect');
1818

19+
expect(imports).toContain('compose');
1920
expect(imports).toContain('composeStores');
2021
expect(imports).toContain('bindActionCreators');
2122
});

0 commit comments

Comments
 (0)