Skip to content

Commit 516206e

Browse files
committed
Testing Delete with custom endpoint
1 parent 3cd1d8c commit 516206e

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/__tests__/createAPIAction-test.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ describe('createAPIAction()', () => {
248248
const payload = { id: 10, name: 'james' };
249249
expect(createItem(payload)).to.deep.equal({
250250
type,
251-
payload: payload,
251+
payload,
252252
meta: {
253253
api: true,
254254
method: 'POST',
@@ -270,7 +270,7 @@ describe('createAPIAction()', () => {
270270
const payload = { id: 10, name: 'james' };
271271
expect(updateItem(payload)).to.deep.equal({
272272
type,
273-
payload: payload,
273+
payload,
274274
meta: {
275275
api: true,
276276
method: 'PUT',
@@ -284,5 +284,27 @@ describe('createAPIAction()', () => {
284284
});
285285
});
286286

287+
it('test DELETE with Custom Endpoint', () => {
288+
const customEndpoint = ({id, accountID}) => {
289+
return `/user/${id}/account/${accountID}`;
290+
};
291+
const deleteItem = createAPIAction(type, 'DELETE', customEndpoint);
292+
const payload = { id: 10, accountID: 25 };
293+
expect(deleteItem(payload)).to.deep.equal({
294+
type,
295+
payload,
296+
meta: {
297+
api: true,
298+
method: 'DELETE',
299+
endpoint: '/user/10/account/25',
300+
types: [
301+
type.concat('_DELETE_REQUEST'),
302+
type.concat('_DELETE_SUCCESS'),
303+
type.concat('_DELETE_FAILURE')
304+
]
305+
}
306+
});
307+
});
308+
287309
});
288310
});

0 commit comments

Comments
 (0)