Skip to content

Commit 92c5f10

Browse files
authored
Merge pull request #55 from sean1292/testing
Testing
2 parents cc205f5 + 3a2c4e4 commit 92c5f10

File tree

2 files changed

+228
-80
lines changed

2 files changed

+228
-80
lines changed

src/actions/__tests__/actionCreator.test.tsx

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,166 @@ describe('Testing All of The Action Creators', () => {
4646
};
4747
expect(actions.changeImagePath(payld)).toEqual(expectedAction);
4848
});
49+
50+
it('deleteChild returns a proper action', () => {
51+
const payld = {};
52+
const expectedAction = {
53+
type: types.DELETE_CHILD,
54+
payload: {}
55+
};
56+
expect(actions.deleteChild(payld)).toEqual(expectedAction);
57+
});
58+
59+
it('changeComponentFocusChild returns a proper action', () => {
60+
const payld = { componentId: 1, childId: 2 };
61+
const expectedAction = {
62+
type: types.CHANGE_COMPONENT_FOCUS_CHILD,
63+
payload: payld
64+
};
65+
expect(actions.changeComponentFocusChild(payld)).toEqual(expectedAction);
66+
});
67+
68+
it('changeFocusChild returns a proper action', () => {
69+
const payld = { childId: 2 };
70+
const expectedAction = {
71+
type: types.CHANGE_FOCUS_CHILD,
72+
payload: payld
73+
};
74+
expect(actions.changeFocusChild(payld)).toEqual(expectedAction);
75+
});
76+
77+
it('changeFocusComponent returns a proper action', () => {
78+
const payld = { title: 'Test' };
79+
const expectedAction = {
80+
type: types.CHANGE_FOCUS_COMPONENT,
81+
payload: payld
82+
};
83+
expect(actions.changeFocusComponent(payld)).toEqual(expectedAction);
84+
});
85+
86+
it('deleteAllData returns a proper action', () => {
87+
const expectedAction = {
88+
type: types.DELETE_ALL_DATA
89+
};
90+
expect(actions.deleteAllData()).toEqual(expectedAction);
91+
});
92+
93+
it('deleteImage returns a proper action', () => {
94+
const expectedAction = {
95+
type: types.DELETE_IMAGE
96+
};
97+
expect(actions.deleteImage()).toEqual(expectedAction);
98+
});
99+
100+
it('deleteProp returns a proper action', () => {
101+
const payld = 2;
102+
const expectedAction = {
103+
type: types.DELETE_PROP,
104+
payload: payld
105+
};
106+
expect(actions.deleteProp(payld)).toEqual(expectedAction);
107+
});
108+
109+
it('editComponent returns a proper action', () => {
110+
const payld = { id: 1, title: 'Test' };
111+
const expectedAction = {
112+
type: types.EDIT_COMPONENT,
113+
payload: payld
114+
};
115+
expect(actions.editComponent(payld)).toEqual(expectedAction);
116+
});
117+
118+
it('handleClose returns a proper action', () => {
119+
const expectedAction = {
120+
type: types.HANDLE_CLOSE,
121+
payload: false
122+
};
123+
expect(actions.handleClose()).toEqual(expectedAction);
124+
});
125+
126+
it('handleTransform returns a proper action', () => {
127+
const payld = { x: 100, y: 200, width: 50, height: 75 };
128+
const componentId = 2;
129+
const childId = 3;
130+
const expectedAction = {
131+
type: types.HANDLE_TRANSFORM,
132+
payload: { componentId, childId, ...payld }
133+
};
134+
expect(actions.handleTransform(componentId, childId, payld)).toEqual(
135+
expectedAction
136+
);
137+
});
138+
139+
it('redo returns a proper action', () => {
140+
const expectedAction = {
141+
type: types.REDO
142+
};
143+
expect(actions.redo()).toEqual(expectedAction);
144+
});
145+
146+
it('toggleComponentState returns a proper action', () => {
147+
const payld = { id: 2 };
148+
const expectedAction = {
149+
type: types.TOGGLE_STATE,
150+
payload: payld
151+
};
152+
expect(actions.toggleComponentState(payld)).toEqual(expectedAction);
153+
});
154+
155+
it('toggleComponentClass returns a proper action', () => {
156+
const payld = { id: 2 };
157+
const expectedAction = {
158+
type: types.TOGGLE_CLASS,
159+
payload: payld
160+
};
161+
expect(actions.toggleComponentClass(payld)).toEqual(expectedAction);
162+
});
163+
164+
it('toggleEditMode returns a proper action', () => {
165+
const payld = { id: 2 };
166+
const expectedAction = {
167+
type: types.EDIT_MODE,
168+
payload: payld
169+
};
170+
expect(actions.toggleEditMode(payld)).toEqual(expectedAction);
171+
});
172+
173+
it('toggleNative returns a proper action', () => {
174+
const expectedAction = {
175+
type: types.TOGGLE_NATIVE
176+
};
177+
expect(actions.toggleNative()).toEqual(expectedAction);
178+
});
179+
180+
it('undo returns a proper action', () => {
181+
const expectedAction = {
182+
type: types.UNDO
183+
};
184+
expect(actions.undo()).toEqual(expectedAction);
185+
});
186+
187+
it('toggleCodeEdit returns a proper action', () => {
188+
const expectedAction = {
189+
type: types.CODE_EDIT
190+
};
191+
expect(actions.toggleCodeEdit()).toEqual(expectedAction);
192+
});
193+
194+
it('updateCode returns a proper action', () => {
195+
const payld = { componentId: 2, code: 'test code' };
196+
const expectedAction = {
197+
type: types.UPDATE_CODE,
198+
payload: payld
199+
};
200+
expect(actions.updateCode(payld)).toEqual(expectedAction);
201+
});
202+
203+
it('updateHtmlAttr returns a proper action', () => {
204+
const payld = { attr: 'form', value: 'test' };
205+
const expectedAction = {
206+
type: types.UPDATE_HTML_ATTR,
207+
payload: payld
208+
};
209+
expect(actions.updateHtmlAttr(payld)).toEqual(expectedAction);
210+
});
49211
});

0 commit comments

Comments
 (0)