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
d565b30c
Commit
d565b30c
authored
Jun 06, 2017
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add jasmine spec for searchState
parent
f1dc6b57
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
2 deletions
+47
-2
app/assets/javascripts/filtered_search/filtered_search_manager.js
...ts/javascripts/filtered_search/filtered_search_manager.js
+4
-2
spec/javascripts/filtered_search/filtered_search_manager_spec.js
...vascripts/filtered_search/filtered_search_manager_spec.js
+43
-0
No files found.
app/assets/javascripts/filtered_search/filtered_search_manager.js
View file @
d565b30c
...
@@ -506,9 +506,11 @@ class FilteredSearchManager {
...
@@ -506,9 +506,11 @@ class FilteredSearchManager {
// return class name that has a prefix of `state-`
// return class name that has a prefix of `state-`
const
stateClassName
=
[].
find
.
call
(
target
.
classList
,
name
=>
name
.
match
(
/
(
state-
)(\w
+
)
/g
));
const
stateClassName
=
[].
find
.
call
(
target
.
classList
,
name
=>
name
.
match
(
/
(
state-
)(\w
+
)
/g
));
const
state
=
stateClassName
.
replace
(
'
state-
'
,
''
);
this
.
search
(
state
);
if
(
stateClassName
)
{
const
state
=
stateClassName
.
replace
(
'
state-
'
,
''
);
this
.
search
(
state
);
}
}
}
search
(
state
=
null
)
{
search
(
state
=
null
)
{
...
...
spec/javascripts/filtered_search/filtered_search_manager_spec.js
View file @
d565b30c
...
@@ -97,6 +97,49 @@ describe('Filtered Search Manager', () => {
...
@@ -97,6 +97,49 @@ describe('Filtered Search Manager', () => {
});
});
});
});
describe
(
'
searchState
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
gl
.
FilteredSearchManager
.
prototype
,
'
search
'
).
and
.
callFake
(()
=>
{});
});
it
(
'
should blur button
'
,
()
=>
{
const
e
=
{
currentTarget
:
{
blur
:
()
=>
{},
classList
:
[],
},
};
spyOn
(
e
.
currentTarget
,
'
blur
'
).
and
.
callThrough
();
manager
.
searchState
(
e
);
expect
(
e
.
currentTarget
.
blur
).
toHaveBeenCalled
();
});
it
(
'
should not call search if there is no state
'
,
()
=>
{
const
e
=
{
currentTarget
:
{
blur
:
()
=>
{},
classList
:
[],
},
};
manager
.
searchState
(
e
);
expect
(
gl
.
FilteredSearchManager
.
prototype
.
search
).
not
.
toHaveBeenCalled
();
});
it
(
'
should call search when there is state
'
,
()
=>
{
const
e
=
{
currentTarget
:
{
blur
:
()
=>
{},
classList
:
[
'
class-name
'
,
'
state-opened
'
],
},
};
manager
.
searchState
(
e
);
expect
(
gl
.
FilteredSearchManager
.
prototype
.
search
).
toHaveBeenCalledWith
(
'
opened
'
);
});
});
describe
(
'
search
'
,
()
=>
{
describe
(
'
search
'
,
()
=>
{
const
defaultParams
=
'
?scope=all&utf8=%E2%9C%93&state=opened
'
;
const
defaultParams
=
'
?scope=all&utf8=%E2%9C%93&state=opened
'
;
...
...
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