Skip to content

Commit 733eb7f

Browse files
authored
Merge pull request #30 from andrefgneves/patch-1
Don't prepend success/error suffixes with "_"
2 parents ac43ce0 + bb27764 commit 733eb7f

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

src/getActionTypes.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export const SUCCESS_SUFFIX = 'SUCCESS';
2-
export const ERROR_SUFFIX = 'FAIL';
1+
export const SUCCESS_SUFFIX = '_SUCCESS';
2+
export const ERROR_SUFFIX = '_FAIL';
33

44
export const getActionTypes = (action, {
55
errorSuffix = ERROR_SUFFIX,
@@ -8,7 +8,7 @@ export const getActionTypes = (action, {
88
let types;
99
if (typeof action.type !== 'undefined') {
1010
const { type } = action;
11-
types = [type, `${type}_${successSuffix}`, `${type}_${errorSuffix}`];
11+
types = [type, `${type}${successSuffix}`, `${type}${errorSuffix}`];
1212
} else if (typeof action.types !== 'undefined') {
1313
types = action.types;
1414
} else {

test/getActionTypes.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ describe('getActionTypes', () => {
88
const types = getActionTypes(action);
99
expect(types).to.be.array;
1010
expect(types[0]).to.equal(action.type);
11-
expect(types[1]).to.equal(`${action.type}_${SUCCESS_SUFFIX}`);
12-
expect(types[2]).to.equal(`${action.type}_${ERROR_SUFFIX}`);
11+
expect(types[1]).to.equal(`${action.type}${SUCCESS_SUFFIX}`);
12+
expect(types[2]).to.equal(`${action.type}${ERROR_SUFFIX}`);
1313
});
1414

1515
it('should return custom types with `types` key', () => {
@@ -35,27 +35,27 @@ describe('getActionTypes', () => {
3535

3636
it('should use custom success sufix if defined', () => {
3737
const action = {type:'TYPE'};
38-
const types = getActionTypes(action, {successSuffix:'AWESOME'});
38+
const types = getActionTypes(action, {successSuffix:'_AWESOME'});
3939
expect(types).to.be.array;
4040
expect(types[0]).to.equal(action.type);
4141
expect(types[1]).to.equal(`${action.type}_AWESOME`);
42-
expect(types[2]).to.equal(`${action.type}_${ERROR_SUFFIX}`);
42+
expect(types[2]).to.equal(`${action.type}${ERROR_SUFFIX}`);
4343
});
4444

4545
it('should use custom error sufix if defined', () => {
4646
const action = {type:'TYPE'};
47-
const types = getActionTypes(action, {errorSuffix:'OH_NO'});
47+
const types = getActionTypes(action, {errorSuffix:'_OH_NO'});
4848
expect(types).to.be.array;
4949
expect(types[0]).to.equal(action.type);
50-
expect(types[1]).to.equal(`${action.type}_${SUCCESS_SUFFIX}`);
50+
expect(types[1]).to.equal(`${action.type}${SUCCESS_SUFFIX}`);
5151
expect(types[2]).to.equal(`${action.type}_OH_NO`);
5252
});
5353

5454
it('should use custom success and error sufix if defined', () => {
5555
const action = {type:'TYPE'};
5656
const types = getActionTypes(action,{
57-
successSuffix:'AWESOME',
58-
errorSuffix:'OH_NO'
57+
successSuffix:'_AWESOME',
58+
errorSuffix:'_OH_NO'
5959
});
6060
expect(types).to.be.array;
6161
expect(types[0]).to.equal(action.type);
@@ -64,7 +64,3 @@ describe('getActionTypes', () => {
6464
});
6565

6666
});
67-
68-
69-
70-

0 commit comments

Comments
 (0)