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
Léo-Paul Géneau
gitlab-ce
Commits
327d73ba
Commit
327d73ba
authored
Feb 05, 2018
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Import and use `FilteredSearchTokenKeys` independently
parent
a6571089
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
27 deletions
+30
-27
spec/javascripts/filtered_search/components/recent_searches_dropdown_content_spec.js
...earch/components/recent_searches_dropdown_content_spec.js
+3
-3
spec/javascripts/filtered_search/dropdown_user_spec.js
spec/javascripts/filtered_search/dropdown_user_spec.js
+3
-1
spec/javascripts/filtered_search/dropdown_utils_spec.js
spec/javascripts/filtered_search/dropdown_utils_spec.js
+2
-1
spec/javascripts/filtered_search/filtered_search_token_keys_spec.js
...cripts/filtered_search/filtered_search_token_keys_spec.js
+20
-20
spec/javascripts/filtered_search/filtered_search_tokenizer_spec.js
...scripts/filtered_search/filtered_search_tokenizer_spec.js
+2
-2
No files found.
spec/javascripts/filtered_search/components/recent_searches_dropdown_content_spec.js
View file @
327d73ba
...
@@ -2,7 +2,7 @@ import Vue from 'vue';
...
@@ -2,7 +2,7 @@ import Vue from 'vue';
import
eventHub
from
'
~/filtered_search/event_hub
'
;
import
eventHub
from
'
~/filtered_search/event_hub
'
;
import
RecentSearchesDropdownContent
from
'
~/filtered_search/components/recent_searches_dropdown_content
'
;
import
RecentSearchesDropdownContent
from
'
~/filtered_search/components/recent_searches_dropdown_content
'
;
import
'
~/filtered_search/filtered_search_token_keys
'
;
import
FilteredSearchTokenKeys
from
'
~/filtered_search/filtered_search_token_keys
'
;
const
createComponent
=
(
propsData
)
=>
{
const
createComponent
=
(
propsData
)
=>
{
const
Component
=
Vue
.
extend
(
RecentSearchesDropdownContent
);
const
Component
=
Vue
.
extend
(
RecentSearchesDropdownContent
);
...
@@ -19,14 +19,14 @@ const trimMarkupWhitespace = text => text.replace(/(\n|\s)+/gm, ' ').trim();
...
@@ -19,14 +19,14 @@ const trimMarkupWhitespace = text => text.replace(/(\n|\s)+/gm, ' ').trim();
describe
(
'
RecentSearchesDropdownContent
'
,
()
=>
{
describe
(
'
RecentSearchesDropdownContent
'
,
()
=>
{
const
propsDataWithoutItems
=
{
const
propsDataWithoutItems
=
{
items
:
[],
items
:
[],
allowedKeys
:
gl
.
FilteredSearchTokenKeys
.
getKeys
(),
allowedKeys
:
FilteredSearchTokenKeys
.
getKeys
(),
};
};
const
propsDataWithItems
=
{
const
propsDataWithItems
=
{
items
:
[
items
:
[
'
foo
'
,
'
foo
'
,
'
author:@root label:~foo bar
'
,
'
author:@root label:~foo bar
'
,
],
],
allowedKeys
:
gl
.
FilteredSearchTokenKeys
.
getKeys
(),
allowedKeys
:
FilteredSearchTokenKeys
.
getKeys
(),
};
};
let
vm
;
let
vm
;
...
...
spec/javascripts/filtered_search/dropdown_user_spec.js
View file @
327d73ba
...
@@ -3,6 +3,8 @@ import '~/filtered_search/filtered_search_tokenizer';
...
@@ -3,6 +3,8 @@ import '~/filtered_search/filtered_search_tokenizer';
import
'
~/filtered_search/filtered_search_dropdown
'
;
import
'
~/filtered_search/filtered_search_dropdown
'
;
import
'
~/filtered_search/dropdown_user
'
;
import
'
~/filtered_search/dropdown_user
'
;
import
FilteredSearchTokenKeys
from
'
~/filtered_search/filtered_search_token_keys
'
;
describe
(
'
Dropdown User
'
,
()
=>
{
describe
(
'
Dropdown User
'
,
()
=>
{
describe
(
'
getSearchInput
'
,
()
=>
{
describe
(
'
getSearchInput
'
,
()
=>
{
let
dropdownUser
;
let
dropdownUser
;
...
@@ -14,7 +16,7 @@ describe('Dropdown User', () => {
...
@@ -14,7 +16,7 @@ describe('Dropdown User', () => {
spyOn
(
gl
.
DropdownUtils
,
'
getSearchInput
'
).
and
.
callFake
(()
=>
{});
spyOn
(
gl
.
DropdownUtils
,
'
getSearchInput
'
).
and
.
callFake
(()
=>
{});
dropdownUser
=
new
gl
.
DropdownUser
({
dropdownUser
=
new
gl
.
DropdownUser
({
tokenKeys
:
gl
.
FilteredSearchTokenKeys
,
tokenKeys
:
FilteredSearchTokenKeys
,
});
});
});
});
...
...
spec/javascripts/filtered_search/dropdown_utils_spec.js
View file @
327d73ba
import
'
~/filtered_search/dropdown_utils
'
;
import
'
~/filtered_search/dropdown_utils
'
;
import
'
~/filtered_search/filtered_search_tokenizer
'
;
import
'
~/filtered_search/filtered_search_tokenizer
'
;
import
'
~/filtered_search/filtered_search_dropdown_manager
'
;
import
'
~/filtered_search/filtered_search_dropdown_manager
'
;
import
FilteredSearchTokenKeys
from
'
~/filtered_search/filtered_search_token_keys
'
;
import
FilteredSearchSpecHelper
from
'
../helpers/filtered_search_spec_helper
'
;
import
FilteredSearchSpecHelper
from
'
../helpers/filtered_search_spec_helper
'
;
describe
(
'
Dropdown Utils
'
,
()
=>
{
describe
(
'
Dropdown Utils
'
,
()
=>
{
...
@@ -137,7 +138,7 @@ describe('Dropdown Utils', () => {
...
@@ -137,7 +138,7 @@ describe('Dropdown Utils', () => {
`
);
`
);
input
=
document
.
getElementById
(
'
test
'
);
input
=
document
.
getElementById
(
'
test
'
);
allowedKeys
=
gl
.
FilteredSearchTokenKeys
.
getKeys
();
allowedKeys
=
FilteredSearchTokenKeys
.
getKeys
();
});
});
function
config
()
{
function
config
()
{
...
...
spec/javascripts/filtered_search/filtered_search_token_keys_spec.js
View file @
327d73ba
import
'
~/filtered_search/filtered_search_token_keys
'
;
import
FilteredSearchTokenKeys
from
'
~/filtered_search/filtered_search_token_keys
'
;
describe
(
'
Filtered Search Token Keys
'
,
()
=>
{
describe
(
'
Filtered Search Token Keys
'
,
()
=>
{
describe
(
'
get
'
,
()
=>
{
describe
(
'
get
'
,
()
=>
{
let
tokenKeys
;
let
tokenKeys
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
tokenKeys
=
gl
.
FilteredSearchTokenKeys
.
get
();
tokenKeys
=
FilteredSearchTokenKeys
.
get
();
});
});
it
(
'
should return tokenKeys
'
,
()
=>
{
it
(
'
should return tokenKeys
'
,
()
=>
{
...
@@ -21,7 +21,7 @@ describe('Filtered Search Token Keys', () => {
...
@@ -21,7 +21,7 @@ describe('Filtered Search Token Keys', () => {
let
conditions
;
let
conditions
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
conditions
=
gl
.
FilteredSearchTokenKeys
.
getConditions
();
conditions
=
FilteredSearchTokenKeys
.
getConditions
();
});
});
it
(
'
should return conditions
'
,
()
=>
{
it
(
'
should return conditions
'
,
()
=>
{
...
@@ -35,71 +35,71 @@ describe('Filtered Search Token Keys', () => {
...
@@ -35,71 +35,71 @@ describe('Filtered Search Token Keys', () => {
describe
(
'
searchByKey
'
,
()
=>
{
describe
(
'
searchByKey
'
,
()
=>
{
it
(
'
should return null when key not found
'
,
()
=>
{
it
(
'
should return null when key not found
'
,
()
=>
{
const
tokenKey
=
gl
.
FilteredSearchTokenKeys
.
searchByKey
(
'
notakey
'
);
const
tokenKey
=
FilteredSearchTokenKeys
.
searchByKey
(
'
notakey
'
);
expect
(
tokenKey
===
null
).
toBe
(
true
);
expect
(
tokenKey
===
null
).
toBe
(
true
);
});
});
it
(
'
should return tokenKey when found by key
'
,
()
=>
{
it
(
'
should return tokenKey when found by key
'
,
()
=>
{
const
tokenKeys
=
gl
.
FilteredSearchTokenKeys
.
get
();
const
tokenKeys
=
FilteredSearchTokenKeys
.
get
();
const
result
=
gl
.
FilteredSearchTokenKeys
.
searchByKey
(
tokenKeys
[
0
].
key
);
const
result
=
FilteredSearchTokenKeys
.
searchByKey
(
tokenKeys
[
0
].
key
);
expect
(
result
).
toEqual
(
tokenKeys
[
0
]);
expect
(
result
).
toEqual
(
tokenKeys
[
0
]);
});
});
});
});
describe
(
'
searchBySymbol
'
,
()
=>
{
describe
(
'
searchBySymbol
'
,
()
=>
{
it
(
'
should return null when symbol not found
'
,
()
=>
{
it
(
'
should return null when symbol not found
'
,
()
=>
{
const
tokenKey
=
gl
.
FilteredSearchTokenKeys
.
searchBySymbol
(
'
notasymbol
'
);
const
tokenKey
=
FilteredSearchTokenKeys
.
searchBySymbol
(
'
notasymbol
'
);
expect
(
tokenKey
===
null
).
toBe
(
true
);
expect
(
tokenKey
===
null
).
toBe
(
true
);
});
});
it
(
'
should return tokenKey when found by symbol
'
,
()
=>
{
it
(
'
should return tokenKey when found by symbol
'
,
()
=>
{
const
tokenKeys
=
gl
.
FilteredSearchTokenKeys
.
get
();
const
tokenKeys
=
FilteredSearchTokenKeys
.
get
();
const
result
=
gl
.
FilteredSearchTokenKeys
.
searchBySymbol
(
tokenKeys
[
0
].
symbol
);
const
result
=
FilteredSearchTokenKeys
.
searchBySymbol
(
tokenKeys
[
0
].
symbol
);
expect
(
result
).
toEqual
(
tokenKeys
[
0
]);
expect
(
result
).
toEqual
(
tokenKeys
[
0
]);
});
});
});
});
describe
(
'
searchByKeyParam
'
,
()
=>
{
describe
(
'
searchByKeyParam
'
,
()
=>
{
it
(
'
should return null when key param not found
'
,
()
=>
{
it
(
'
should return null when key param not found
'
,
()
=>
{
const
tokenKey
=
gl
.
FilteredSearchTokenKeys
.
searchByKeyParam
(
'
notakeyparam
'
);
const
tokenKey
=
FilteredSearchTokenKeys
.
searchByKeyParam
(
'
notakeyparam
'
);
expect
(
tokenKey
===
null
).
toBe
(
true
);
expect
(
tokenKey
===
null
).
toBe
(
true
);
});
});
it
(
'
should return tokenKey when found by key param
'
,
()
=>
{
it
(
'
should return tokenKey when found by key param
'
,
()
=>
{
const
tokenKeys
=
gl
.
FilteredSearchTokenKeys
.
get
();
const
tokenKeys
=
FilteredSearchTokenKeys
.
get
();
const
result
=
gl
.
FilteredSearchTokenKeys
.
searchByKeyParam
(
`
${
tokenKeys
[
0
].
key
}
_
${
tokenKeys
[
0
].
param
}
`
);
const
result
=
FilteredSearchTokenKeys
.
searchByKeyParam
(
`
${
tokenKeys
[
0
].
key
}
_
${
tokenKeys
[
0
].
param
}
`
);
expect
(
result
).
toEqual
(
tokenKeys
[
0
]);
expect
(
result
).
toEqual
(
tokenKeys
[
0
]);
});
});
it
(
'
should return alternative tokenKey when found by key param
'
,
()
=>
{
it
(
'
should return alternative tokenKey when found by key param
'
,
()
=>
{
const
tokenKeys
=
gl
.
FilteredSearchTokenKeys
.
getAlternatives
();
const
tokenKeys
=
FilteredSearchTokenKeys
.
getAlternatives
();
const
result
=
gl
.
FilteredSearchTokenKeys
.
searchByKeyParam
(
`
${
tokenKeys
[
0
].
key
}
_
${
tokenKeys
[
0
].
param
}
`
);
const
result
=
FilteredSearchTokenKeys
.
searchByKeyParam
(
`
${
tokenKeys
[
0
].
key
}
_
${
tokenKeys
[
0
].
param
}
`
);
expect
(
result
).
toEqual
(
tokenKeys
[
0
]);
expect
(
result
).
toEqual
(
tokenKeys
[
0
]);
});
});
});
});
describe
(
'
searchByConditionUrl
'
,
()
=>
{
describe
(
'
searchByConditionUrl
'
,
()
=>
{
it
(
'
should return null when condition url not found
'
,
()
=>
{
it
(
'
should return null when condition url not found
'
,
()
=>
{
const
condition
=
gl
.
FilteredSearchTokenKeys
.
searchByConditionUrl
(
null
);
const
condition
=
FilteredSearchTokenKeys
.
searchByConditionUrl
(
null
);
expect
(
condition
===
null
).
toBe
(
true
);
expect
(
condition
===
null
).
toBe
(
true
);
});
});
it
(
'
should return condition when found by url
'
,
()
=>
{
it
(
'
should return condition when found by url
'
,
()
=>
{
const
conditions
=
gl
.
FilteredSearchTokenKeys
.
getConditions
();
const
conditions
=
FilteredSearchTokenKeys
.
getConditions
();
const
result
=
gl
.
FilteredSearchTokenKeys
.
searchByConditionUrl
(
conditions
[
0
].
url
);
const
result
=
FilteredSearchTokenKeys
.
searchByConditionUrl
(
conditions
[
0
].
url
);
expect
(
result
).
toBe
(
conditions
[
0
]);
expect
(
result
).
toBe
(
conditions
[
0
]);
});
});
});
});
describe
(
'
searchByConditionKeyValue
'
,
()
=>
{
describe
(
'
searchByConditionKeyValue
'
,
()
=>
{
it
(
'
should return null when condition tokenKey and value not found
'
,
()
=>
{
it
(
'
should return null when condition tokenKey and value not found
'
,
()
=>
{
const
condition
=
gl
.
FilteredSearchTokenKeys
.
searchByConditionKeyValue
(
null
,
null
);
const
condition
=
FilteredSearchTokenKeys
.
searchByConditionKeyValue
(
null
,
null
);
expect
(
condition
===
null
).
toBe
(
true
);
expect
(
condition
===
null
).
toBe
(
true
);
});
});
it
(
'
should return condition when found by tokenKey and value
'
,
()
=>
{
it
(
'
should return condition when found by tokenKey and value
'
,
()
=>
{
const
conditions
=
gl
.
FilteredSearchTokenKeys
.
getConditions
();
const
conditions
=
FilteredSearchTokenKeys
.
getConditions
();
const
result
=
gl
.
FilteredSearchTokenKeys
const
result
=
FilteredSearchTokenKeys
.
searchByConditionKeyValue
(
conditions
[
0
].
tokenKey
,
conditions
[
0
].
value
);
.
searchByConditionKeyValue
(
conditions
[
0
].
tokenKey
,
conditions
[
0
].
value
);
expect
(
result
).
toEqual
(
conditions
[
0
]);
expect
(
result
).
toEqual
(
conditions
[
0
]);
});
});
...
...
spec/javascripts/filtered_search/filtered_search_tokenizer_spec.js
View file @
327d73ba
import
'
~/filtered_search/filtered_search_token_keys
'
;
import
FilteredSearchTokenKeys
from
'
~/filtered_search/filtered_search_token_keys
'
;
import
'
~/filtered_search/filtered_search_tokenizer
'
;
import
'
~/filtered_search/filtered_search_tokenizer
'
;
describe
(
'
Filtered Search Tokenizer
'
,
()
=>
{
describe
(
'
Filtered Search Tokenizer
'
,
()
=>
{
const
allowedKeys
=
gl
.
FilteredSearchTokenKeys
.
getKeys
();
const
allowedKeys
=
FilteredSearchTokenKeys
.
getKeys
();
describe
(
'
processTokens
'
,
()
=>
{
describe
(
'
processTokens
'
,
()
=>
{
it
(
'
returns for input containing only search value
'
,
()
=>
{
it
(
'
returns for input containing only search value
'
,
()
=>
{
...
...
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