Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sample_pdp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Praveen Reghunathan Nair
sample_pdp
Commits
b6739fa4
Commit
b6739fa4
authored
Feb 07, 2020
by
Praveen Reghunathan Nair
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added test for Redux actions
parent
efa13327
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
0 deletions
+44
-0
category.spec.js
src/redux/actions/category.spec.js
+20
-0
product.spec.js
src/redux/actions/product.spec.js
+24
-0
No files found.
src/redux/actions/category.spec.js
0 → 100644
View file @
b6739fa4
import
*
as
actions
from
'./category'
;
import
{
CATEGORY_ACTION_TYPE
}
from
'redux/constants/ActionTypes'
;
const
{
CATEGORY_INIT_BEGIN
,
CATEGORY_INIT_SUCCESS
,
CATEGORY_INIT_FAILED
}
=
CATEGORY_ACTION_TYPE
;
describe
(
'Category Actions - logic'
,
()
=>
{
describe
(
'initCategory -logic'
,
()
=>
{
it
(
'initCategory should be defined'
,
()
=>
{
expect
(
typeof
actions
.
initCategory
()).
toBe
(
'function'
);
});
it
(
'should call redux dispatch'
,
()
=>
{
const
initCallBack
=
actions
.
initCategory
();
const
mockDispatch
=
jest
.
fn
();
initCallBack
(
mockDispatch
);
expect
(
mockDispatch
).
toHaveBeenCalledWith
({
type
:
CATEGORY_INIT_BEGIN
});
});
});
});
src/redux/actions/product.spec.js
0 → 100644
View file @
b6739fa4
import
*
as
actions
from
'./product'
;
import
{
PRODUCT_ACTION_TYPE
}
from
'redux/constants/actionTypes'
;
import
API
from
'services/api'
;
const
{
PRODUCT_INIT_BEGIN
,
PRODUCT_INIT_SUCCESS
,
PRODUCT_INIT_FAILED
}
=
PRODUCT_ACTION_TYPE
;
describe
(
'Product Actions - logic'
,
()
=>
{
describe
(
'getProductDetails -logic'
,
()
=>
{
it
(
'getProductDetails should be defined'
,
()
=>
{
expect
(
typeof
actions
.
getProductDetails
()).
toBe
(
'function'
);
});
it
(
'should call redux dispatch'
,
()
=>
{
const
getProductDetailsSpy
=
jest
.
spyOn
(
API
,
'getProductDetails'
);
getProductDetailsSpy
.
mockImplementation
(()
=>
Promise
.
resolve
({}));
const
mockDispatch
=
jest
.
fn
();
const
productCallBack
=
actions
.
getProductDetails
(
'test'
);
productCallBack
(
mockDispatch
);
expect
(
mockDispatch
).
toHaveBeenCalledWith
({
type
:
PRODUCT_INIT_BEGIN
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment