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
3d0c4092
Commit
3d0c4092
authored
Oct 04, 2021
by
Scott Stern
Committed by
Kushal Pandya
Oct 04, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add guard to base token handleInput
parent
55df8936
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
14 deletions
+39
-14
app/assets/javascripts/vue_shared/components/filtered_search_bar/tokens/base_token.vue
...ared/components/filtered_search_bar/tokens/base_token.vue
+2
-1
spec/frontend/vue_shared/components/filtered_search_bar/tokens/base_token_spec.js
.../components/filtered_search_bar/tokens/base_token_spec.js
+37
-13
No files found.
app/assets/javascripts/vue_shared/components/filtered_search_bar/tokens/base_token.vue
View file @
3d0c4092
...
...
@@ -148,7 +148,8 @@ export default {
methods
:
{
handleInput
:
debounce
(
function
debouncedSearch
({
data
})
{
this
.
searchKey
=
data
;
if
(
!
this
.
suggestionsLoading
)
{
if
(
!
this
.
suggestionsLoading
&&
!
this
.
activeTokenValue
)
{
this
.
$emit
(
'
fetch-suggestions
'
,
data
);
}
},
DEBOUNCE_DELAY
),
...
...
spec/frontend/vue_shared/components/filtered_search_bar/tokens/base_token_spec.js
View file @
3d0c4092
...
...
@@ -206,26 +206,50 @@ describe('BaseToken', () => {
describe
(
'
events
'
,
()
=>
{
let
wrapperWithNoStubs
;
beforeEach
(()
=>
{
wrapperWithNoStubs
=
createComponent
({
stubs
:
{
Portal
:
true
},
});
});
afterEach
(()
=>
{
wrapperWithNoStubs
.
destroy
();
});
it
(
'
emits `fetch-suggestions` event on component after a delay when component emits `input` event
'
,
async
()
=>
{
jest
.
useFakeTimers
();
describe
(
'
when activeToken has been selected
'
,
()
=>
{
beforeEach
(()
=>
{
wrapperWithNoStubs
=
createComponent
({
props
:
{
...
mockProps
,
getActiveTokenValue
:
()
=>
({
title
:
''
}),
suggestionsLoading
:
true
,
},
stubs
:
{
Portal
:
true
},
});
});
it
(
'
does not emit `fetch-suggestions` event on component after a delay when component emits `input` event
'
,
async
()
=>
{
jest
.
useFakeTimers
();
wrapperWithNoStubs
.
find
(
GlFilteredSearchToken
).
vm
.
$emit
(
'
input
'
,
{
data
:
'
foo
'
});
await
wrapperWithNoStubs
.
vm
.
$nextTick
();
wrapperWithNoStubs
.
find
(
GlFilteredSearchToken
).
vm
.
$emit
(
'
input
'
,
{
data
:
'
foo
'
});
await
wrapperWithNoStubs
.
vm
.
$nextTick
();
jest
.
runAllTimers
();
jest
.
runAllTimers
();
expect
(
wrapperWithNoStubs
.
emitted
(
'
fetch-suggestions
'
)).
toBeTruthy
();
expect
(
wrapperWithNoStubs
.
emitted
(
'
fetch-suggestions
'
)[
2
]).
toEqual
([
'
foo
'
]);
expect
(
wrapperWithNoStubs
.
emitted
(
'
fetch-suggestions
'
)).
toEqual
([[
''
]]);
});
});
describe
(
'
when activeToken has not been selected
'
,
()
=>
{
beforeEach
(()
=>
{
wrapperWithNoStubs
=
createComponent
({
stubs
:
{
Portal
:
true
},
});
});
it
(
'
emits `fetch-suggestions` event on component after a delay when component emits `input` event
'
,
async
()
=>
{
jest
.
useFakeTimers
();
wrapperWithNoStubs
.
find
(
GlFilteredSearchToken
).
vm
.
$emit
(
'
input
'
,
{
data
:
'
foo
'
});
await
wrapperWithNoStubs
.
vm
.
$nextTick
();
jest
.
runAllTimers
();
expect
(
wrapperWithNoStubs
.
emitted
(
'
fetch-suggestions
'
)).
toBeTruthy
();
expect
(
wrapperWithNoStubs
.
emitted
(
'
fetch-suggestions
'
)[
2
]).
toEqual
([
'
foo
'
]);
});
});
});
});
...
...
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