Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
0bb1009c
Commit
0bb1009c
authored
Jul 19, 2018
by
Lukas Eipert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow for testAction to wait until all promises are resolved
parent
66f5be83
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
7 deletions
+30
-7
spec/javascripts/helpers/vuex_action_helper.js
spec/javascripts/helpers/vuex_action_helper.js
+5
-7
spec/javascripts/helpers/vuex_action_helper_spec.js
spec/javascripts/helpers/vuex_action_helper_spec.js
+25
-0
No files found.
spec/javascripts/helpers/vuex_action_helper.js
View file @
0bb1009c
...
...
@@ -84,14 +84,12 @@ export default (
done
();
};
return
new
Promise
((
resolve
,
reject
)
=>
{
try
{
const
result
=
action
({
commit
,
state
,
dispatch
,
rootState
:
state
},
payload
);
resolve
(
result
);
}
catch
(
e
)
{
reject
(
e
);
}
return
new
Promise
(
resolve
=>
{
setImmediate
(
resolve
);
})
.
then
(()
=>
result
)
.
catch
(
error
=>
{
validateResults
();
throw
error
;
...
...
spec/javascripts/helpers/vuex_action_helper_spec.js
View file @
0bb1009c
...
...
@@ -138,4 +138,29 @@ describe('VueX test helper (testAction)', () => {
});
});
});
it
(
'
should work with async actions not returning promises
'
,
done
=>
{
const
data
=
{
FOO
:
'
BAR
'
};
const
promiseAction
=
({
commit
,
dispatch
})
=>
{
dispatch
(
'
ACTION
'
);
axios
.
get
(
TEST_HOST
)
.
then
(()
=>
{
commit
(
'
SUCCESS
'
);
return
data
;
})
.
catch
(
error
=>
{
commit
(
'
ERROR
'
);
throw
error
;
});
};
mock
.
onGet
(
TEST_HOST
).
replyOnce
(
200
,
42
);
assertion
=
{
mutations
:
[{
type
:
'
SUCCESS
'
}],
actions
:
[{
type
:
'
ACTION
'
}]
};
testAction
(
promiseAction
,
null
,
{},
assertion
.
mutations
,
assertion
.
actions
,
done
);
});
});
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