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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
97699bbd
Commit
97699bbd
authored
Aug 02, 2019
by
Sam Beckham
Committed by
Paul Slaughter
Aug 02, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Syncs the vue test utils helpers
parent
2d72602b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
36 deletions
+20
-36
spec/frontend/helpers/vue_test_utils_helper.js
spec/frontend/helpers/vue_test_utils_helper.js
+16
-2
spec/frontend/helpers/vue_test_utils_helper_spec.js
spec/frontend/helpers/vue_test_utils_helper_spec.js
+0
-0
spec/javascripts/helpers/vue_test_utils_helper.js
spec/javascripts/helpers/vue_test_utils_helper.js
+4
-34
No files found.
spec/frontend/helpers/vue_test_utils_helper.js
View file @
97699bbd
/* eslint-disable import/prefer-default-export */
const
vNodeContainsText
=
(
vnode
,
text
)
=>
const
vNodeContainsText
=
(
vnode
,
text
)
=>
(
vnode
.
text
&&
vnode
.
text
.
includes
(
text
))
||
(
vnode
.
text
&&
vnode
.
text
.
includes
(
text
))
||
(
vnode
.
children
&&
vnode
.
children
.
filter
(
child
=>
vNodeContainsText
(
child
,
text
)).
length
);
(
vnode
.
children
&&
vnode
.
children
.
filter
(
child
=>
vNodeContainsText
(
child
,
text
)).
length
);
...
@@ -19,3 +17,19 @@ export const shallowWrapperContainsSlotText = (shallowWrapper, slotName, text) =
...
@@ -19,3 +17,19 @@ export const shallowWrapperContainsSlotText = (shallowWrapper, slotName, text) =
Boolean
(
Boolean
(
shallowWrapper
.
vm
.
$slots
[
slotName
].
filter
(
vnode
=>
vNodeContainsText
(
vnode
,
text
)).
length
,
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
();
}
});
});
spec/
javascripts
/helpers/vue_test_utils_helper_spec.js
→
spec/
frontend
/helpers/vue_test_utils_helper_spec.js
View file @
97699bbd
File moved
spec/javascripts/helpers/vue_test_utils_helper.js
View file @
97699bbd
const
vNodeContainsText
=
(
vnode
,
text
)
=>
// No new code should be added to this file. Instead, modify the
(
vnode
.
text
&&
vnode
.
text
.
includes
(
text
))
||
// file this one re-exports from. For more detail about why, see:
(
vnode
.
children
&&
vnode
.
children
.
filter
(
child
=>
vNodeContainsText
(
child
,
text
)).
length
);
// https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/31349
/**
export
*
from
'
../../frontend/helpers/vue_test_utils_helper
'
;
* Determines whether a `shallowMount` Wrapper contains text
* within one of it's slots. This will also work on Wrappers
* acquired with `find()`, but only if it's parent Wrapper
* was shallowMounted.
* NOTE: Prefer checking the rendered output of a component
* wherever possible using something like `text()` instead.
* @param {Wrapper} shallowWrapper - Vue test utils wrapper (shallowMounted)
* @param {String} slotName
* @param {String} text
*/
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