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
cc807277
Commit
cc807277
authored
Sep 04, 2017
by
kushalpandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Projects Dropdown Search Component Spec
parent
399d8ffc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
101 additions
and
0 deletions
+101
-0
spec/javascripts/projects_dropdown/components/search_spec.js
spec/javascripts/projects_dropdown/components/search_spec.js
+101
-0
No files found.
spec/javascripts/projects_dropdown/components/search_spec.js
0 → 100644
View file @
cc807277
import
Vue
from
'
vue
'
;
import
searchComponent
from
'
~/projects_dropdown/components/search.vue
'
;
import
eventHub
from
'
~/projects_dropdown/event_hub
'
;
import
mountComponent
from
'
../../helpers/vue_mount_component_helper
'
;
const
createComponent
=
()
=>
{
const
Component
=
Vue
.
extend
(
searchComponent
);
return
mountComponent
(
Component
);
};
describe
(
'
SearchComponent
'
,
()
=>
{
describe
(
'
methods
'
,
()
=>
{
let
vm
;
beforeEach
(()
=>
{
vm
=
createComponent
();
});
afterEach
(()
=>
{
vm
.
$destroy
();
});
describe
(
'
setFocus
'
,
()
=>
{
it
(
'
should set focus to search input
'
,
()
=>
{
spyOn
(
vm
.
$refs
.
search
,
'
focus
'
);
vm
.
setFocus
();
expect
(
vm
.
$refs
.
search
.
focus
).
toHaveBeenCalled
();
});
});
describe
(
'
emitSearchEvents
'
,
()
=>
{
it
(
'
should emit `searchProjects` event via eventHub when `searchQuery` present
'
,
()
=>
{
const
searchQuery
=
'
test
'
;
spyOn
(
eventHub
,
'
$emit
'
);
vm
.
searchQuery
=
searchQuery
;
vm
.
emitSearchEvents
();
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
'
searchProjects
'
,
searchQuery
);
});
it
(
'
should emit `searchCleared` event via eventHub when `searchQuery` is cleared
'
,
()
=>
{
spyOn
(
eventHub
,
'
$emit
'
);
vm
.
searchQuery
=
''
;
vm
.
emitSearchEvents
();
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
'
searchCleared
'
);
});
});
});
describe
(
'
mounted
'
,
()
=>
{
it
(
'
should listen `dropdownOpen` event
'
,
(
done
)
=>
{
spyOn
(
eventHub
,
'
$on
'
);
createComponent
();
Vue
.
nextTick
(()
=>
{
expect
(
eventHub
.
$on
).
toHaveBeenCalledWith
(
'
dropdownOpen
'
,
jasmine
.
any
(
Function
));
done
();
});
});
});
describe
(
'
beforeDestroy
'
,
()
=>
{
it
(
'
should unbind event listeners on eventHub
'
,
(
done
)
=>
{
const
vm
=
createComponent
();
spyOn
(
eventHub
,
'
$off
'
);
vm
.
$mount
();
vm
.
$destroy
();
Vue
.
nextTick
(()
=>
{
expect
(
eventHub
.
$off
).
toHaveBeenCalledWith
(
'
dropdownOpen
'
,
jasmine
.
any
(
Function
));
done
();
});
});
});
describe
(
'
template
'
,
()
=>
{
let
vm
;
beforeEach
(()
=>
{
vm
=
createComponent
();
});
afterEach
(()
=>
{
vm
.
$destroy
();
});
it
(
'
should render component element
'
,
()
=>
{
const
inputEl
=
vm
.
$el
.
querySelector
(
'
input.form-control
'
);
expect
(
vm
.
$el
.
classList
.
contains
(
'
search-input-container
'
)).
toBeTruthy
();
expect
(
vm
.
$el
.
classList
.
contains
(
'
hidden-xs
'
)).
toBeTruthy
();
expect
(
inputEl
).
not
.
toBe
(
null
);
expect
(
inputEl
.
getAttribute
(
'
placeholder
'
)).
toBe
(
'
Search projects
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.search-icon
'
)).
toBeDefined
();
});
});
});
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