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
0bc9b770
Commit
0bc9b770
authored
Jun 28, 2019
by
samdbeckham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds a waitForMutation helper for VueX
parent
9c3dfd20
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
+16
-2
spec/javascripts/helpers/vue_test_utils_helper.js
spec/javascripts/helpers/vue_test_utils_helper.js
+16
-2
No files found.
spec/javascripts/helpers/vue_test_utils_helper.js
View file @
0bc9b770
/* eslint-disable import/prefer-default-export */
const
vNodeContainsText
=
(
vnode
,
text
)
=>
(
vnode
.
text
&&
vnode
.
text
.
includes
(
text
))
||
(
vnode
.
children
&&
vnode
.
children
.
filter
(
child
=>
vNodeContainsText
(
child
,
text
)).
length
);
...
...
@@ -19,3 +17,19 @@ export const shallowWrapperContainsSlotText = (shallowWrapper, slotName, text) =
Boolean
(
shallowWrapper
.
vm
.
$slots
[
slotName
].
filter
(
vnode
=>
vNodeContainsText
(
vnode
,
text
)).
length
,
);
/**
* Returns a promise that waits for a mutation to be fired before resolving
* NOTE: There's no reject action here so it will hang if it waits for a mutation that won't happen.
* @param {Object} store - The Vue store that contains the mutations
* @param {String} expectedMutationType - The Mutation to wait for
*/
export
const
waitForMutation
=
(
store
,
expectedMutationType
)
=>
new
Promise
(
resolve
=>
{
const
unsubscribe
=
store
.
subscribe
(
mutation
=>
{
if
(
mutation
.
type
===
expectedMutationType
)
{
unsubscribe
();
resolve
();
}
});
});
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