Skip to content

Commit cf94044

Browse files
committed
added tests for 2 action creators
1 parent 5f7ed67 commit cf94044

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import * as actions from '../actionCreators';
2+
import * as types from '../../actionTypes/index';
3+
4+
describe('Testing All of The Action Creators', () => {
5+
it('addComponent returns a proper action', () => {
6+
const payld = { title: 'Test' };
7+
const expectedAction = {
8+
type: types.ADD_COMPONENT,
9+
payload: payld
10+
};
11+
expect(actions.addComponent(payld)).toEqual(expectedAction);
12+
});
13+
it('addChild returns a proper action', () => {
14+
const payld = { title: 'Test', childType: 'COMP', HTMLInfo: {} };
15+
const expectedAction = {
16+
type: types.ADD_CHILD,
17+
payload: payld
18+
};
19+
expect(actions.addChild(payld)).toEqual(expectedAction);
20+
});
21+
});

src/actions/actionCreators.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,14 @@ export const addChild = ({
5757
payload: { title: string; childType: string; HTMLInfo: object };
5858
} => ({ type: ADD_CHILD, payload: { title, childType, HTMLInfo } });
5959

60-
export const addComponent = ({ title }: { title: string }) => ({
60+
export const addComponent = ({
61+
title
62+
}: {
63+
title: string;
64+
}): {
65+
type: string;
66+
payload: { title: string };
67+
} => ({
6168
type: ADD_COMPONENT,
6269
payload: { title }
6370
});

0 commit comments

Comments
 (0)