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
e49d15e7
Commit
e49d15e7
authored
Feb 23, 2021
by
Justin Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor specs to include new prop
parent
f2062bc0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
20 deletions
+25
-20
spec/frontend/vue_shared/components/sidebar/labels_select_vue/dropdown_value_spec.js
...mponents/sidebar/labels_select_vue/dropdown_value_spec.js
+24
-20
spec/frontend/vue_shared/components/sidebar/labels_select_vue/mock_data.js
..._shared/components/sidebar/labels_select_vue/mock_data.js
+1
-0
No files found.
spec/frontend/vue_shared/components/sidebar/labels_select_vue/dropdown_value_spec.js
View file @
e49d15e7
...
...
@@ -11,32 +11,31 @@ import { mockConfig, mockRegularLabel, mockScopedLabel } from './mock_data';
const
localVue
=
createLocalVue
();
localVue
.
use
(
Vuex
);
const
createComponent
=
(
initialState
=
mockConfig
,
slots
=
{})
=>
{
const
store
=
new
Vuex
.
Store
(
labelsSelectModule
());
store
.
dispatch
(
'
setInitialState
'
,
initialState
);
return
shallowMount
(
DropdownValue
,
{
localVue
,
store
,
slots
,
});
};
describe
(
'
DropdownValue
'
,
()
=>
{
let
wrapper
;
beforeEach
(()
=>
{
wrapper
=
createComponent
();
});
const
createComponent
=
(
initialState
=
{},
slots
=
{})
=>
{
const
store
=
new
Vuex
.
Store
(
labelsSelectModule
());
store
.
dispatch
(
'
setInitialState
'
,
{
...
mockConfig
,
...
initialState
});
wrapper
=
shallowMount
(
DropdownValue
,
{
localVue
,
store
,
slots
,
});
};
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
=
null
;
});
describe
(
'
methods
'
,
()
=>
{
describe
(
'
labelFilterUrl
'
,
()
=>
{
it
(
'
returns a label filter URL based on provided label param
'
,
()
=>
{
createComponent
();
expect
(
wrapper
.
vm
.
labelFilterUrl
(
mockRegularLabel
)).
toBe
(
'
/gitlab-org/my-project/issues?label_name[]=Foo%20Label
'
,
);
...
...
@@ -44,6 +43,10 @@ describe('DropdownValue', () => {
});
describe
(
'
scopedLabel
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
();
});
it
(
'
returns `true` when provided label param is a scoped label
'
,
()
=>
{
expect
(
wrapper
.
vm
.
scopedLabel
(
mockScopedLabel
)).
toBe
(
true
);
});
...
...
@@ -56,28 +59,29 @@ describe('DropdownValue', () => {
describe
(
'
template
'
,
()
=>
{
it
(
'
renders class `has-labels` on component container element when `selectedLabels` is not empty
'
,
()
=>
{
createComponent
();
expect
(
wrapper
.
attributes
(
'
class
'
)).
toContain
(
'
has-labels
'
);
});
it
(
'
renders element containing `None` when `selectedLabels` is empty
'
,
()
=>
{
c
onst
wrapperNoLabels
=
c
reateComponent
(
createComponent
(
{
...
mockConfig
,
selectedLabels
:
[],
},
{
default
:
'
None
'
,
},
);
const
noneEl
=
wrapper
NoLabels
.
find
(
'
span.text-secondary
'
);
const
noneEl
=
wrapper
.
find
(
'
span.text-secondary
'
);
expect
(
noneEl
.
exists
()).
toBe
(
true
);
expect
(
noneEl
.
text
()).
toBe
(
'
None
'
);
wrapperNoLabels
.
destroy
();
});
it
(
'
renders labels when `selectedLabels` is not empty
'
,
()
=>
{
createComponent
();
expect
(
wrapper
.
findAll
(
GlLabel
).
length
).
toBe
(
2
);
});
});
...
...
spec/frontend/vue_shared/components/sidebar/labels_select_vue/mock_data.js
View file @
e49d15e7
...
...
@@ -47,6 +47,7 @@ export const mockConfig = {
labelsFetchPath
:
'
/gitlab-org/my-project/-/labels.json
'
,
labelsManagePath
:
'
/gitlab-org/my-project/-/labels
'
,
labelsFilterBasePath
:
'
/gitlab-org/my-project/issues
'
,
labelsFilterParam
:
'
label_name
'
,
};
export
const
mockSuggestedColors
=
{
...
...
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