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
3f71e91a
Commit
3f71e91a
authored
Mar 30, 2021
by
peterhegman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch to using vm.$options.provide() to check provide/inject
Instead of using `_provided`
parent
9b62b6af
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
61 deletions
+4
-61
spec/frontend/__helpers__/vue_test_utils_helper.js
spec/frontend/__helpers__/vue_test_utils_helper.js
+0
-10
spec/frontend/__helpers__/vue_test_utils_helper_spec.js
spec/frontend/__helpers__/vue_test_utils_helper_spec.js
+0
-47
spec/frontend/members/index_spec.js
spec/frontend/members/index_spec.js
+4
-4
No files found.
spec/frontend/__helpers__/vue_test_utils_helper.js
View file @
3f71e91a
...
...
@@ -56,15 +56,5 @@ export const extendedWrapper = (wrapper) => {
return
this
.
findAll
(
`[data-testid="
${
id
}
"]`
);
},
},
// Returns attributes provided to the component via provide/inject
// https://vuejs.org/v2/api/#provide-inject
provided
:
{
value
(
key
)
{
// eslint-disable-next-line no-underscore-dangle
const
provided
=
this
.
vm
?.
_provided
||
{};
return
key
?
provided
[
key
]
:
provided
;
},
},
});
};
spec/frontend/__helpers__/vue_test_utils_helper_spec.js
View file @
3f71e91a
...
...
@@ -105,52 +105,5 @@ describe('Vue test utils helpers', () => {
expect
(
mockComponent
.
findAllByTestId
(
testId
)).
toHaveLength
(
2
);
});
});
describe
(
'
provided
'
,
()
=>
{
let
wrapper
;
beforeEach
(()
=>
{
wrapper
=
extendedWrapper
(
shallowMount
({
template
:
'
<div>mock component</div>
'
,
provide
:
{
fooBar
:
'
baz
'
,
company
:
'
GitLab
'
},
}),
);
});
describe
(
'
when called without `key` argument
'
,
()
=>
{
it
(
'
returns an object of provided attributes
'
,
()
=>
{
expect
(
wrapper
.
provided
()).
toEqual
({
fooBar
:
'
baz
'
,
company
:
'
GitLab
'
});
});
});
describe
(
'
when called with `key` argument
'
,
()
=>
{
describe
(
'
when `key` exists in provided attributes
'
,
()
=>
{
it
(
'
returns value of provided attribute
'
,
()
=>
{
expect
(
wrapper
.
provided
(
'
fooBar
'
)).
toBe
(
'
baz
'
);
});
});
describe
(
'
when `key` does not exist in provided attributes
'
,
()
=>
{
it
(
'
returns `undefined`
'
,
()
=>
{
expect
(
wrapper
.
provided
(
'
invalidKey
'
)).
toBeUndefined
();
});
});
});
describe
(
'
when no attributes are provided
'
,
()
=>
{
beforeEach
(()
=>
{
wrapper
=
extendedWrapper
(
shallowMount
({
template
:
'
<div>mock component</div>
'
,
}),
);
});
it
(
'
returns an empty object
'
,
()
=>
{
expect
(
wrapper
.
provided
()).
toEqual
({});
});
});
});
});
});
spec/frontend/members/index_spec.js
View file @
3f71e91a
...
...
@@ -46,7 +46,7 @@ describe('initMembersApp', () => {
it
(
'
sets `currentUserId` in provide/inject
'
,
()
=>
{
setup
();
expect
(
wrapper
.
provided
(
'
currentUserId
'
)
).
toBe
(
123
);
expect
(
vm
.
$options
.
provide
().
currentUserId
).
toBe
(
123
);
});
describe
(
'
when `gon.current_user_id` is not set (user is not logged in)
'
,
()
=>
{
...
...
@@ -54,20 +54,20 @@ describe('initMembersApp', () => {
window
.
gon
=
{};
setup
();
expect
(
wrapper
.
provided
(
'
currentUserId
'
)
).
toBeNull
();
expect
(
vm
.
$options
.
provide
().
currentUserId
).
toBeNull
();
});
});
it
(
'
parses and sets `data-source-id` as `sourceId` in provide/inject
'
,
()
=>
{
setup
();
expect
(
wrapper
.
provided
(
'
sourceId
'
)
).
toBe
(
234
);
expect
(
vm
.
$options
.
provide
().
sourceId
).
toBe
(
234
);
});
it
(
'
parses and sets `data-can-manage-members` as `canManageMembers` in Vuex store
'
,
()
=>
{
setup
();
expect
(
wrapper
.
provided
(
'
canManageMembers
'
)
).
toBe
(
true
);
expect
(
vm
.
$options
.
provide
().
canManageMembers
).
toBe
(
true
);
});
it
(
'
parses and sets `members` in Vuex store
'
,
()
=>
{
...
...
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