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
bcb14156
Commit
bcb14156
authored
Jan 10, 2018
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update tests to cover modal dialog
parent
a2ae0f85
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
12 deletions
+54
-12
spec/javascripts/groups/components/app_spec.js
spec/javascripts/groups/components/app_spec.js
+54
-12
No files found.
spec/javascripts/groups/components/app_spec.js
View file @
bcb14156
...
@@ -256,6 +256,36 @@ describe('AppComponent', () => {
...
@@ -256,6 +256,36 @@ describe('AppComponent', () => {
});
});
});
});
describe
(
'
showLeaveGroupModal
'
,
()
=>
{
it
(
'
caches candidate group (as props) which is to be left
'
,
()
=>
{
const
group
=
Object
.
assign
({},
mockParentGroupItem
);
expect
(
vm
.
targetGroup
).
toBe
(
null
);
expect
(
vm
.
targetParentGroup
).
toBe
(
null
);
vm
.
showLeaveGroupModal
(
group
,
mockParentGroupItem
);
expect
(
vm
.
targetGroup
).
not
.
toBe
(
null
);
expect
(
vm
.
targetParentGroup
).
not
.
toBe
(
null
);
});
it
(
'
updates props which show modal confirmation dialog
'
,
()
=>
{
const
group
=
Object
.
assign
({},
mockParentGroupItem
);
expect
(
vm
.
showModal
).
toBeFalsy
();
expect
(
vm
.
groupLeaveConfirmationMessage
).
toBe
(
''
);
vm
.
showLeaveGroupModal
(
group
,
mockParentGroupItem
);
expect
(
vm
.
showModal
).
toBeTruthy
();
expect
(
vm
.
groupLeaveConfirmationMessage
).
toBe
(
`Are you sure you want to leave the "
${
group
.
fullName
}
" group?`
);
});
});
describe
(
'
hideLeaveGroupModal
'
,
()
=>
{
it
(
'
hides modal confirmation which is shown before leaving the group
'
,
()
=>
{
const
group
=
Object
.
assign
({},
mockParentGroupItem
);
vm
.
showLeaveGroupModal
(
group
,
mockParentGroupItem
);
expect
(
vm
.
showModal
).
toBeTruthy
();
vm
.
hideLeaveGroupModal
();
expect
(
vm
.
showModal
).
toBeFalsy
();
});
});
describe
(
'
leaveGroup
'
,
()
=>
{
describe
(
'
leaveGroup
'
,
()
=>
{
let
groupItem
;
let
groupItem
;
let
childGroupItem
;
let
childGroupItem
;
...
@@ -265,21 +295,24 @@ describe('AppComponent', () => {
...
@@ -265,21 +295,24 @@ describe('AppComponent', () => {
groupItem
.
children
=
mockChildren
;
groupItem
.
children
=
mockChildren
;
childGroupItem
=
groupItem
.
children
[
0
];
childGroupItem
=
groupItem
.
children
[
0
];
groupItem
.
isChildrenLoading
=
false
;
groupItem
.
isChildrenLoading
=
false
;
vm
.
targetGroup
=
childGroupItem
;
vm
.
targetParentGroup
=
groupItem
;
});
});
it
(
'
should
leave group and remove group item from tree
'
,
(
done
)
=>
{
it
(
'
hides modal confirmation
leave group and remove group item from tree
'
,
(
done
)
=>
{
const
notice
=
`You left the "
${
childGroupItem
.
fullName
}
" group.`
;
const
notice
=
`You left the "
${
childGroupItem
.
fullName
}
" group.`
;
spyOn
(
vm
.
service
,
'
leaveGroup
'
).
and
.
returnValue
(
returnServicePromise
({
notice
}));
spyOn
(
vm
.
service
,
'
leaveGroup
'
).
and
.
returnValue
(
returnServicePromise
({
notice
}));
spyOn
(
vm
.
store
,
'
removeGroup
'
).
and
.
callThrough
();
spyOn
(
vm
.
store
,
'
removeGroup
'
).
and
.
callThrough
();
spyOn
(
window
,
'
Flash
'
);
spyOn
(
window
,
'
Flash
'
);
spyOn
(
$
,
'
scrollTo
'
);
spyOn
(
$
,
'
scrollTo
'
);
vm
.
leaveGroup
(
childGroupItem
,
groupItem
);
vm
.
leaveGroup
();
expect
(
childGroupItem
.
isBeingRemoved
).
toBeTruthy
();
expect
(
vm
.
showModal
).
toBeFalsy
();
expect
(
vm
.
service
.
leaveGroup
).
toHaveBeenCalledWith
(
childGroupItem
.
leavePath
);
expect
(
vm
.
targetGroup
.
isBeingRemoved
).
toBeTruthy
();
expect
(
vm
.
service
.
leaveGroup
).
toHaveBeenCalledWith
(
vm
.
targetGroup
.
leavePath
);
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
$
.
scrollTo
).
toHaveBeenCalledWith
(
0
);
expect
(
$
.
scrollTo
).
toHaveBeenCalledWith
(
0
);
expect
(
vm
.
store
.
removeGroup
).
toHaveBeenCalledWith
(
childGroupItem
,
groupItem
);
expect
(
vm
.
store
.
removeGroup
).
toHaveBeenCalledWith
(
vm
.
targetGroup
,
vm
.
targetParentGroup
);
expect
(
window
.
Flash
).
toHaveBeenCalledWith
(
notice
,
'
notice
'
);
expect
(
window
.
Flash
).
toHaveBeenCalledWith
(
notice
,
'
notice
'
);
done
();
done
();
},
0
);
},
0
);
...
@@ -291,13 +324,13 @@ describe('AppComponent', () => {
...
@@ -291,13 +324,13 @@ describe('AppComponent', () => {
spyOn
(
vm
.
store
,
'
removeGroup
'
).
and
.
callThrough
();
spyOn
(
vm
.
store
,
'
removeGroup
'
).
and
.
callThrough
();
spyOn
(
window
,
'
Flash
'
);
spyOn
(
window
,
'
Flash
'
);
vm
.
leaveGroup
(
childGroupItem
,
groupItem
);
vm
.
leaveGroup
();
expect
(
childGroupItem
.
isBeingRemoved
).
toBeTruthy
();
expect
(
vm
.
targetGroup
.
isBeingRemoved
).
toBeTruthy
();
expect
(
vm
.
service
.
leaveGroup
).
toHaveBeenCalledWith
(
childGroupItem
.
leavePath
);
expect
(
vm
.
service
.
leaveGroup
).
toHaveBeenCalledWith
(
childGroupItem
.
leavePath
);
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
vm
.
store
.
removeGroup
).
not
.
toHaveBeenCalled
();
expect
(
vm
.
store
.
removeGroup
).
not
.
toHaveBeenCalled
();
expect
(
window
.
Flash
).
toHaveBeenCalledWith
(
message
);
expect
(
window
.
Flash
).
toHaveBeenCalledWith
(
message
);
expect
(
childGroupItem
.
isBeingRemoved
).
toBeFalsy
();
expect
(
vm
.
targetGroup
.
isBeingRemoved
).
toBeFalsy
();
done
();
done
();
},
0
);
},
0
);
});
});
...
@@ -309,12 +342,12 @@ describe('AppComponent', () => {
...
@@ -309,12 +342,12 @@ describe('AppComponent', () => {
spyOn
(
window
,
'
Flash
'
);
spyOn
(
window
,
'
Flash
'
);
vm
.
leaveGroup
(
childGroupItem
,
groupItem
);
vm
.
leaveGroup
(
childGroupItem
,
groupItem
);
expect
(
childGroupItem
.
isBeingRemoved
).
toBeTruthy
();
expect
(
vm
.
targetGroup
.
isBeingRemoved
).
toBeTruthy
();
expect
(
vm
.
service
.
leaveGroup
).
toHaveBeenCalledWith
(
childGroupItem
.
leavePath
);
expect
(
vm
.
service
.
leaveGroup
).
toHaveBeenCalledWith
(
childGroupItem
.
leavePath
);
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
vm
.
store
.
removeGroup
).
not
.
toHaveBeenCalled
();
expect
(
vm
.
store
.
removeGroup
).
not
.
toHaveBeenCalled
();
expect
(
window
.
Flash
).
toHaveBeenCalledWith
(
message
);
expect
(
window
.
Flash
).
toHaveBeenCalledWith
(
message
);
expect
(
childGroupItem
.
isBeingRemoved
).
toBeFalsy
();
expect
(
vm
.
targetGroup
.
isBeingRemoved
).
toBeFalsy
();
done
();
done
();
},
0
);
},
0
);
});
});
...
@@ -364,7 +397,7 @@ describe('AppComponent', () => {
...
@@ -364,7 +397,7 @@ describe('AppComponent', () => {
Vue
.
nextTick
(()
=>
{
Vue
.
nextTick
(()
=>
{
expect
(
eventHub
.
$on
).
toHaveBeenCalledWith
(
'
fetchPage
'
,
jasmine
.
any
(
Function
));
expect
(
eventHub
.
$on
).
toHaveBeenCalledWith
(
'
fetchPage
'
,
jasmine
.
any
(
Function
));
expect
(
eventHub
.
$on
).
toHaveBeenCalledWith
(
'
toggleChildren
'
,
jasmine
.
any
(
Function
));
expect
(
eventHub
.
$on
).
toHaveBeenCalledWith
(
'
toggleChildren
'
,
jasmine
.
any
(
Function
));
expect
(
eventHub
.
$on
).
toHaveBeenCalledWith
(
'
leaveGroup
'
,
jasmine
.
any
(
Function
));
expect
(
eventHub
.
$on
).
toHaveBeenCalledWith
(
'
showLeaveGroupModal
'
,
jasmine
.
any
(
Function
));
expect
(
eventHub
.
$on
).
toHaveBeenCalledWith
(
'
updatePagination
'
,
jasmine
.
any
(
Function
));
expect
(
eventHub
.
$on
).
toHaveBeenCalledWith
(
'
updatePagination
'
,
jasmine
.
any
(
Function
));
expect
(
eventHub
.
$on
).
toHaveBeenCalledWith
(
'
updateGroups
'
,
jasmine
.
any
(
Function
));
expect
(
eventHub
.
$on
).
toHaveBeenCalledWith
(
'
updateGroups
'
,
jasmine
.
any
(
Function
));
newVm
.
$destroy
();
newVm
.
$destroy
();
...
@@ -404,7 +437,7 @@ describe('AppComponent', () => {
...
@@ -404,7 +437,7 @@ describe('AppComponent', () => {
Vue
.
nextTick
(()
=>
{
Vue
.
nextTick
(()
=>
{
expect
(
eventHub
.
$off
).
toHaveBeenCalledWith
(
'
fetchPage
'
,
jasmine
.
any
(
Function
));
expect
(
eventHub
.
$off
).
toHaveBeenCalledWith
(
'
fetchPage
'
,
jasmine
.
any
(
Function
));
expect
(
eventHub
.
$off
).
toHaveBeenCalledWith
(
'
toggleChildren
'
,
jasmine
.
any
(
Function
));
expect
(
eventHub
.
$off
).
toHaveBeenCalledWith
(
'
toggleChildren
'
,
jasmine
.
any
(
Function
));
expect
(
eventHub
.
$off
).
toHaveBeenCalledWith
(
'
leaveGroup
'
,
jasmine
.
any
(
Function
));
expect
(
eventHub
.
$off
).
toHaveBeenCalledWith
(
'
showLeaveGroupModal
'
,
jasmine
.
any
(
Function
));
expect
(
eventHub
.
$off
).
toHaveBeenCalledWith
(
'
updatePagination
'
,
jasmine
.
any
(
Function
));
expect
(
eventHub
.
$off
).
toHaveBeenCalledWith
(
'
updatePagination
'
,
jasmine
.
any
(
Function
));
expect
(
eventHub
.
$off
).
toHaveBeenCalledWith
(
'
updateGroups
'
,
jasmine
.
any
(
Function
));
expect
(
eventHub
.
$off
).
toHaveBeenCalledWith
(
'
updateGroups
'
,
jasmine
.
any
(
Function
));
done
();
done
();
...
@@ -439,5 +472,14 @@ describe('AppComponent', () => {
...
@@ -439,5 +472,14 @@ describe('AppComponent', () => {
done
();
done
();
});
});
});
});
it
(
'
renders modal confirmation dialog
'
,
()
=>
{
vm
.
groupLeaveConfirmationMessage
=
'
Are you sure you want to leave the "foo" group?
'
;
vm
.
showModal
=
true
;
const
modalDialogEl
=
vm
.
$el
.
querySelector
(
'
.modal
'
);
expect
(
modalDialogEl
).
not
.
toBe
(
null
);
expect
(
modalDialogEl
.
querySelector
(
'
.modal-title
'
).
innerText
.
trim
()).
toBe
(
'
Are you sure?
'
);
expect
(
modalDialogEl
.
querySelector
(
'
.btn.btn-warning
'
).
innerText
.
trim
()).
toBe
(
'
Leave
'
);
});
});
});
});
});
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