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
f0a50b55
Commit
f0a50b55
authored
Apr 15, 2021
by
Rajat Jain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FE review fixes
FE review fixes
parent
e4752bdf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
39 deletions
+28
-39
spec/frontend/vue_shared/components/filtered_search_bar/tokens/epic_token_spec.js
.../components/filtered_search_bar/tokens/epic_token_spec.js
+28
-39
No files found.
spec/frontend/vue_shared/components/filtered_search_bar/tokens/epic_token_spec.js
View file @
f0a50b55
...
...
@@ -59,7 +59,6 @@ describe('EpicToken', () => {
describe
(
'
computed
'
,
()
=>
{
beforeEach
(
async
()
=>
{
// Milestone title with spaces is always enclosed in quotations by component.
wrapper
=
createComponent
({
data
:
{
epics
:
mockEpics
,
...
...
@@ -70,29 +69,17 @@ describe('EpicToken', () => {
});
describe
(
'
currentValue
'
,
()
=>
{
it
(
'
returns numeric `iid` when have string as value
'
,
async
()
=>
{
wrapper
.
setProps
({
value
:
{
data
:
`
${
mockEpics
[
0
].
title
}
::&
${
mockEpics
[
0
].
iid
}
`
}
});
await
wrapper
.
vm
.
$nextTick
();
expect
(
wrapper
.
vm
.
currentValue
).
toBe
(
mockEpics
[
0
].
iid
);
});
it
.
each
`
data | id
${
`
${
mockEpics
[
0
].
title
}
::&
${
mockEpics
[
0
].
iid
}
`
}
|
${
mockEpics
[
0
].
iid
}
${
mockEpics
[
0
].
iid
}
|
${
mockEpics
[
0
].
iid
}
${
'
foobar
'
}
|
${
'
foobar
'
}
`
(
'
$data returns $id
'
,
async
({
data
,
id
})
=>
{
wrapper
.
setProps
({
value
:
{
data
}
});
it
(
'
returns numeric `iid` when have numeric string as value
'
,
async
()
=>
{
wrapper
.
setProps
({
value
:
{
data
:
`
${
mockEpics
[
0
].
iid
}
`
},
});
await
wrapper
.
vm
.
$nextTick
();
expect
(
wrapper
.
vm
.
currentValue
).
toBe
(
mockEpics
[
0
].
iid
);
});
it
(
"
returns value when it's not a numeric string
"
,
async
()
=>
{
wrapper
.
setProps
({
value
:
{
data
:
`foobar`
},
});
await
wrapper
.
vm
.
$nextTick
();
expect
(
wrapper
.
vm
.
currentValue
).
toBe
(
'
foobar
'
);
expect
(
wrapper
.
vm
.
currentValue
).
toBe
(
id
);
});
});
...
...
@@ -101,6 +88,7 @@ describe('EpicToken', () => {
wrapper
.
setProps
({
value
:
{
data
:
`
${
mockEpics
[
0
].
iid
}
`
},
});
await
wrapper
.
vm
.
$nextTick
();
expect
(
wrapper
.
vm
.
activeEpic
).
toEqual
(
mockEpics
[
0
]);
...
...
@@ -118,51 +106,52 @@ describe('EpicToken', () => {
expect
(
wrapper
.
vm
.
config
.
fetchEpics
).
toHaveBeenCalledWith
(
'
foo
'
);
});
it
(
'
sets response to `epics` when request is successful
'
,
()
=>
{
it
(
'
sets response to `epics` when request is successful
'
,
async
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
.
config
,
'
fetchEpics
'
).
mockResolvedValue
({
data
:
mockEpics
,
});
wrapper
.
vm
.
fetchEpicsBySearchTerm
();
return
waitForPromises
().
then
(()
=>
{
expect
(
wrapper
.
vm
.
epics
).
toEqual
(
mockEpics
);
}
);
await
waitForPromises
();
expect
(
wrapper
.
vm
.
epics
).
toEqual
(
mockEpics
);
});
it
(
'
calls `createFlash` with flash error message when request fails
'
,
()
=>
{
it
(
'
calls `createFlash` with flash error message when request fails
'
,
async
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
.
config
,
'
fetchEpics
'
).
mockRejectedValue
({});
wrapper
.
vm
.
fetchEpicsBySearchTerm
(
'
foo
'
);
return
waitForPromises
().
then
(()
=>
{
expect
(
createFlash
).
toHaveBeenCalledWith
({
message
:
'
There was a problem fetching epics.
'
,
});
await
waitForPromises
();
expect
(
createFlash
).
toHaveBeenCalledWith
({
message
:
'
There was a problem fetching epics.
'
,
});
});
it
(
'
sets `loading` to false when request completes
'
,
()
=>
{
it
(
'
sets `loading` to false when request completes
'
,
async
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
.
config
,
'
fetchEpics
'
).
mockRejectedValue
({});
wrapper
.
vm
.
fetchEpicsBySearchTerm
(
'
foo
'
);
return
waitForPromises
().
then
(()
=>
{
expect
(
wrapper
.
vm
.
loading
).
toBe
(
false
);
}
);
await
waitForPromises
();
expect
(
wrapper
.
vm
.
loading
).
toBe
(
false
);
});
});
describe
(
'
fetchSingleEpic
'
,
()
=>
{
it
(
'
calls `config.fetchSingleEpic` with provided iid param
'
,
()
=>
{
it
(
'
calls `config.fetchSingleEpic` with provided iid param
'
,
async
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
.
config
,
'
fetchSingleEpic
'
);
wrapper
.
vm
.
fetchSingleEpic
(
1
);
expect
(
wrapper
.
vm
.
config
.
fetchSingleEpic
).
toHaveBeenCalledWith
(
1
);
return
waitForPromises
().
then
(()
=>
{
expect
(
wrapper
.
vm
.
epics
).
toEqual
([
mockEpics
[
0
]]);
});
await
waitForPromises
();
expect
(
wrapper
.
vm
.
epics
).
toEqual
([
mockEpics
[
0
]]);
});
});
});
...
...
@@ -171,7 +160,7 @@ describe('EpicToken', () => {
beforeEach
(
async
()
=>
{
wrapper
=
createComponent
({
value
:
{
data
:
`
${
mockEpics
[
0
].
iid
}
`
},
data
:
{
milestone
s
:
mockEpics
},
data
:
{
epic
s
:
mockEpics
},
});
await
wrapper
.
vm
.
$nextTick
();
...
...
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