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
8701d44c
Commit
8701d44c
authored
Apr 15, 2020
by
sstern
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mv sidebar_assignees to jest
parent
383c0d19
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
0 deletions
+74
-0
spec/frontend/sidebar/sidebar_assignees_spec.js
spec/frontend/sidebar/sidebar_assignees_spec.js
+74
-0
No files found.
spec/
javascripts
/sidebar/sidebar_assignees_spec.js
→
spec/
frontend
/sidebar/sidebar_assignees_spec.js
View file @
8701d44c
import
Vue
from
'
vue
'
;
import
mountComponent
from
'
spec/helpers/vue_mount_component_helper
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
AxiosMockAdapter
from
'
axios-mock-adapter
'
;
import
axios
from
'
axios
'
;
import
SidebarAssignees
from
'
~/sidebar/components/assignees/sidebar_assignees.vue
'
;
import
Assigness
from
'
~/sidebar/components/assignees/assignees.vue
'
;
import
SidebarMediator
from
'
~/sidebar/sidebar_mediator
'
;
import
SidebarService
from
'
~/sidebar/services/sidebar_service
'
;
import
SidebarStore
from
'
~/sidebar/stores/sidebar_store
'
;
import
Mock
from
'
./mock_data
'
;
describe
(
'
sidebar assignees
'
,
()
=>
{
let
vm
;
let
wrapper
;
let
mediator
;
let
sidebarAssigneesEl
;
preloadFixtures
(
'
issues/open-issue.html
'
);
let
axiosMock
;
beforeEach
(()
=>
{
loadFixtures
(
'
issues/open-issue.html
'
);
mediator
=
new
SidebarMediator
(
Mock
.
mediator
);
spyOn
(
mediator
,
'
saveAssignees
'
).
and
.
callThrough
();
spyOn
(
mediator
,
'
assignYourself
'
).
and
.
callThrough
();
const
SidebarAssigneeComponent
=
Vue
.
extend
(
SidebarAssignees
);
sidebarAssigneesEl
=
document
.
querySelector
(
'
#js-vue-sidebar-assignees
'
);
vm
=
mountComponent
(
SidebarAssigneeComponent
,
{
const
createComponent
=
()
=>
{
wrapper
=
shallowMount
(
SidebarAssignees
,
{
propsData
:
{
mediator
,
field
:
sidebarAssigneesEl
.
dataset
.
field
,
field
:
''
,
},
sidebarAssigneesEl
,
);
// Attaching to document is required because this component emits something from the parent element :/
attachToDocument
:
true
,
});
};
beforeEach
(()
=>
{
axiosMock
=
new
AxiosMockAdapter
(
axios
);
mediator
=
new
SidebarMediator
(
Mock
.
mediator
);
jest
.
spyOn
(
mediator
,
'
saveAssignees
'
);
jest
.
spyOn
(
mediator
,
'
assignYourself
'
);
createComponent
();
});
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
=
null
;
SidebarService
.
singleton
=
null
;
SidebarStore
.
singleton
=
null
;
SidebarMediator
.
singleton
=
null
;
axiosMock
.
restore
();
});
it
(
'
calls the mediator when saves the assignees
'
,
()
=>
{
vm
.
saveAssignees
();
expect
(
mediator
.
saveAssignees
).
not
.
toHaveBeenCalled
();
wrapper
.
vm
.
saveAssignees
();
expect
(
mediator
.
saveAssignees
).
toHaveBeenCalled
();
});
it
(
'
calls the mediator when "assignSelf" method is called
'
,
()
=>
{
vm
.
assignSelf
();
expect
(
mediator
.
assignYourself
).
not
.
toHaveBeenCalled
();
expect
(
mediator
.
store
.
assignees
.
length
).
toBe
(
0
);
wrapper
.
vm
.
assignSelf
();
expect
(
mediator
.
assignYourself
).
toHaveBeenCalled
();
expect
(
mediator
.
store
.
assignees
.
length
).
to
Equal
(
1
);
expect
(
mediator
.
store
.
assignees
.
length
).
to
Be
(
1
);
});
it
(
'
hides assignees until fetched
'
,
done
=>
{
const
currentAssignee
=
sidebarAssigneesEl
.
querySelector
(
'
.value
'
);
it
(
'
hides assignees until fetched
'
,
()
=>
{
expect
(
wrapper
.
find
(
Assigness
).
exists
()).
toBe
(
false
);
expect
(
currentAssignee
).
toBe
(
null
)
;
wrapper
.
vm
.
store
.
isFetching
.
assignees
=
false
;
vm
.
store
.
isFetching
.
assignees
=
false
;
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.value
'
)).
toBeVisible
();
done
();
return
wrapper
.
vm
.
$nextTick
(()
=>
{
expect
(
wrapper
.
find
(
Assigness
).
exists
()).
toBe
(
true
);
});
});
});
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