Skip to content

Commit 90e679a

Browse files
Use flux-standard-action dependency for test only
1 parent bfc14b0 commit 90e679a

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
"eslint-config-airbnb-base": "^1.0.3",
3939
"eslint-plugin-import": "^1.5.0",
4040
"lodash.isplainobject": "^3.2.0",
41+
"flux-standard-action": "^0.6.0",
4142
"mocha": "^2.2.5"
4243
},
4344
"dependencies": {
44-
"flux-standard-action": "^0.6.0",
4545
"reduce-reducers": "^0.1.0"
4646
}
4747
}

src/__tests__/createAction-test.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
11
import { createAction } from '../';
2-
import isPlainObject from 'lodash.isplainobject';
2+
import { isFSA } from 'flux-standard-action';
33

44
describe('createAction()', () => {
55
describe('resulting action creator', () => {
66
const type = 'TYPE';
77

8-
it('returns plain object', () => {
8+
it('returns a valid FSA', () => {
99
const actionCreator = createAction(type, b => b);
1010
const foobar = { foo: 'bar' };
1111
const action = actionCreator(foobar);
12-
expect(isPlainObject(action)).to.be.true;
12+
expect(isFSA(action)).to.be.true;
1313
});
1414

1515
it('uses return value as payload', () => {
16-
const actionCreator = createAction(type, b => b);
17-
const foobar = { foo: 'bar' };
18-
const action = actionCreator(foobar);
19-
expect(action.payload).to.equal(foobar);
20-
});
21-
22-
it('has no extraneous keys', () => {
2316
const actionCreator = createAction(type, b => b);
2417
const foobar = { foo: 'bar' };
2518
const action = actionCreator(foobar);
@@ -37,6 +30,7 @@ describe('createAction()', () => {
3730
type,
3831
payload: foobar
3932
});
33+
expect(isFSA(action)).to.be.true;
4034
});
4135

4236
it('accepts a second parameter for adding meta to object', () => {
@@ -50,6 +44,7 @@ describe('createAction()', () => {
5044
cid: 5
5145
}
5246
});
47+
expect(isFSA(action)).to.be.true;
5348
});
5449

5550
it('sets error to true if payload is an Error object', () => {
@@ -62,13 +57,15 @@ describe('createAction()', () => {
6257
payload: errObj,
6358
error: true
6459
});
60+
expect(isFSA(errAction)).to.be.true;
6561

6662
const foobar = { foo: 'bar', cid: 5 };
6763
const noErrAction = actionCreator(foobar);
6864
expect(noErrAction).to.deep.equal({
6965
type,
7066
payload: foobar
7167
});
68+
expect(isFSA(noErrAction)).to.be.true;
7269
});
7370
});
7471
});

src/handleAction.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { isError } from 'flux-standard-action';
2-
31
function isFunction(val) {
42
return typeof val === 'function';
53
}
@@ -9,7 +7,7 @@ export default function handleAction(type, reducers) {
97
// If action type does not match, return previous state
108
if (action.type !== type) return state;
119

12-
const handlerKey = isError(action) ? 'throw' : 'next';
10+
const handlerKey = action.error === true ? 'throw' : 'next';
1311

1412
// If function is passed instead of map, use as reducer
1513
if (isFunction(reducers)) {

0 commit comments

Comments
 (0)