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
4d828eae
Commit
4d828eae
authored
Apr 16, 2018
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
convert remaining instances of import * to use spyOnDependency
parent
704e8661
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
35 additions
and
48 deletions
+35
-48
spec/javascripts/gl_dropdown_spec.js
spec/javascripts/gl_dropdown_spec.js
+3
-4
spec/javascripts/groups/components/app_spec.js
spec/javascripts/groups/components/app_spec.js
+2
-3
spec/javascripts/groups/components/group_item_spec.js
spec/javascripts/groups/components/group_item_spec.js
+2
-3
spec/javascripts/ide/stores/modules/commit/actions_spec.js
spec/javascripts/ide/stores/modules/commit/actions_spec.js
+5
-3
spec/javascripts/issue_show/components/app_spec.js
spec/javascripts/issue_show/components/app_spec.js
+7
-18
spec/javascripts/issue_show/components/description_spec.js
spec/javascripts/issue_show/components/description_spec.js
+8
-7
spec/javascripts/shortcuts_dashboard_navigation_spec.js
spec/javascripts/shortcuts_dashboard_navigation_spec.js
+4
-5
spec/javascripts/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js
...widget/components/states/mr_widget_ready_to_merge_spec.js
+4
-5
No files found.
spec/javascripts/gl_dropdown_spec.js
View file @
4d828eae
/* eslint-disable comma-dangle, no-param-reassign, no-unused-expressions, max-len */
import
$
from
'
jquery
'
;
import
'
~/gl_dropdown
'
;
import
GLDropdown
from
'
~/gl_dropdown
'
;
import
'
~/lib/utils/common_utils
'
;
import
*
as
urlUtils
from
'
~/lib/utils/url_utility
'
;
describe
(
'
glDropdown
'
,
function
describeDropdown
()
{
preloadFixtures
(
'
static/gl_dropdown.html.raw
'
);
...
...
@@ -138,13 +137,13 @@ describe('glDropdown', function describeDropdown() {
expect
(
this
.
dropdownContainerElement
).
toHaveClass
(
'
open
'
);
const
randomIndex
=
Math
.
floor
(
Math
.
random
()
*
(
this
.
projectsData
.
length
-
1
))
+
0
;
navigateWithKeys
(
'
down
'
,
randomIndex
,
()
=>
{
spyOn
(
urlUtils
,
'
visitUrl
'
).
and
.
stub
();
const
visitUrl
=
spyOnDependency
(
GLDropdown
,
'
visitUrl
'
).
and
.
stub
();
navigateWithKeys
(
'
enter
'
,
null
,
()
=>
{
expect
(
this
.
dropdownContainerElement
).
not
.
toHaveClass
(
'
open
'
);
const
link
=
$
(
`
${
ITEM_SELECTOR
}
:eq(
${
randomIndex
}
) a`
,
this
.
$dropdownMenuElement
);
expect
(
link
).
toHaveClass
(
'
is-active
'
);
const
linkedLocation
=
link
.
attr
(
'
href
'
);
if
(
linkedLocation
&&
linkedLocation
!==
'
#
'
)
expect
(
urlUtils
.
visitUrl
).
toHaveBeenCalledWith
(
linkedLocation
);
if
(
linkedLocation
&&
linkedLocation
!==
'
#
'
)
expect
(
visitUrl
).
toHaveBeenCalledWith
(
linkedLocation
);
});
});
});
...
...
spec/javascripts/groups/components/app_spec.js
View file @
4d828eae
import
$
from
'
jquery
'
;
import
Vue
from
'
vue
'
;
import
*
as
utils
from
'
~/lib/utils/url_utility
'
;
import
appComponent
from
'
~/groups/components/app.vue
'
;
import
groupFolderComponent
from
'
~/groups/components/group_folder.vue
'
;
import
groupItemComponent
from
'
~/groups/components/group_item.vue
'
;
...
...
@@ -177,7 +176,7 @@ describe('AppComponent', () => {
it
(
'
should fetch groups for provided page details and update window state
'
,
(
done
)
=>
{
spyOn
(
vm
,
'
fetchGroups
'
).
and
.
returnValue
(
returnServicePromise
(
mockGroups
));
spyOn
(
vm
,
'
updateGroups
'
).
and
.
callThrough
();
spyOn
(
utils
,
'
mergeUrlParams
'
).
and
.
callThrough
();
const
mergeUrlParams
=
spyOnDependency
(
appComponent
,
'
mergeUrlParams
'
).
and
.
callThrough
();
spyOn
(
window
.
history
,
'
replaceState
'
);
spyOn
(
$
,
'
scrollTo
'
);
...
...
@@ -193,7 +192,7 @@ describe('AppComponent', () => {
setTimeout
(()
=>
{
expect
(
vm
.
isLoading
).
toBe
(
false
);
expect
(
$
.
scrollTo
).
toHaveBeenCalledWith
(
0
);
expect
(
utils
.
mergeUrlParams
).
toHaveBeenCalledWith
({
page
:
2
},
jasmine
.
any
(
String
));
expect
(
mergeUrlParams
).
toHaveBeenCalledWith
({
page
:
2
},
jasmine
.
any
(
String
));
expect
(
window
.
history
.
replaceState
).
toHaveBeenCalledWith
({
page
:
jasmine
.
any
(
String
),
},
jasmine
.
any
(
String
),
jasmine
.
any
(
String
));
...
...
spec/javascripts/groups/components/group_item_spec.js
View file @
4d828eae
import
Vue
from
'
vue
'
;
import
*
as
urlUtils
from
'
~/lib/utils/url_utility
'
;
import
groupItemComponent
from
'
~/groups/components/group_item.vue
'
;
import
groupFolderComponent
from
'
~/groups/components/group_folder.vue
'
;
import
eventHub
from
'
~/groups/event_hub
'
;
...
...
@@ -135,13 +134,13 @@ describe('GroupItemComponent', () => {
const
group
=
Object
.
assign
({},
mockParentGroupItem
);
group
.
childrenCount
=
0
;
const
newVm
=
createComponent
(
group
);
spyOn
(
urlUtils
,
'
visitUrl
'
).
and
.
stub
();
const
visitUrl
=
spyOnDependency
(
groupItemComponent
,
'
visitUrl
'
).
and
.
stub
();
spyOn
(
eventHub
,
'
$emit
'
);
newVm
.
onClickRowGroup
(
event
);
setTimeout
(()
=>
{
expect
(
eventHub
.
$emit
).
not
.
toHaveBeenCalled
();
expect
(
urlUtils
.
visitUrl
).
toHaveBeenCalledWith
(
newVm
.
group
.
relativePath
);
expect
(
visitUrl
).
toHaveBeenCalledWith
(
newVm
.
group
.
relativePath
);
done
();
},
0
);
});
...
...
spec/javascripts/ide/stores/modules/commit/actions_spec.js
View file @
4d828eae
import
actions
from
'
~/ide/stores/actions
'
;
import
store
from
'
~/ide/stores
'
;
import
service
from
'
~/ide/services
'
;
import
router
from
'
~/ide/ide_router
'
;
import
*
as
urlUtils
from
'
~/lib/utils/url_utility
'
;
import
eventHub
from
'
~/ide/eventhub
'
;
import
*
as
consts
from
'
~/ide/stores/modules/commit/constants
'
;
import
{
resetStore
,
file
}
from
'
spec/ide/helpers
'
;
...
...
@@ -307,8 +307,10 @@ describe('IDE commit module actions', () => {
});
describe
(
'
commitChanges
'
,
()
=>
{
let
visitUrl
;
beforeEach
(()
=>
{
spyOn
(
urlUtil
s
,
'
visitUrl
'
);
visitUrl
=
spyOnDependency
(
action
s
,
'
visitUrl
'
);
document
.
body
.
innerHTML
+=
'
<div class="flash-container"></div>
'
;
...
...
@@ -461,7 +463,7 @@ describe('IDE commit module actions', () => {
store
.
dispatch
(
'
commit/commitChanges
'
)
.
then
(()
=>
{
expect
(
urlUtils
.
visitUrl
).
toHaveBeenCalledWith
(
expect
(
visitUrl
).
toHaveBeenCalledWith
(
`webUrl/merge_requests/new?merge_request[source_branch]=
${
store
.
getters
[
'
commit/newBranchName
'
]
}
&merge_request[target_branch]=master`
,
...
...
spec/javascripts/issue_show/components/app_spec.js
View file @
4d828eae
...
...
@@ -2,7 +2,6 @@ import Vue from 'vue';
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
'
~/behaviors/markdown/render_gfm
'
;
import
*
as
urlUtils
from
'
~/lib/utils/url_utility
'
;
import
issuableApp
from
'
~/issue_show/components/app.vue
'
;
import
eventHub
from
'
~/issue_show/event_hub
'
;
import
setTimeoutPromise
from
'
spec/helpers/set_timeout_promise_helper
'
;
...
...
@@ -174,7 +173,7 @@ describe('Issuable output', () => {
});
it
(
'
does not redirect if issue has not moved
'
,
(
done
)
=>
{
spyOn
(
urlUtils
,
'
visitUrl
'
);
const
visitUrl
=
spyOnDependency
(
issuableApp
,
'
visitUrl
'
);
spyOn
(
vm
.
service
,
'
updateIssuable
'
).
and
.
callFake
(()
=>
new
Promise
((
resolve
)
=>
{
resolve
({
data
:
{
...
...
@@ -187,16 +186,13 @@ describe('Issuable output', () => {
vm
.
updateIssuable
();
setTimeout
(()
=>
{
expect
(
urlUtils
.
visitUrl
,
).
not
.
toHaveBeenCalled
();
expect
(
visitUrl
).
not
.
toHaveBeenCalled
();
done
();
});
});
it
(
'
redirects if returned web_url has changed
'
,
(
done
)
=>
{
spyOn
(
urlUtils
,
'
visitUrl
'
);
const
visitUrl
=
spyOnDependency
(
issuableApp
,
'
visitUrl
'
);
spyOn
(
vm
.
service
,
'
updateIssuable
'
).
and
.
callFake
(()
=>
new
Promise
((
resolve
)
=>
{
resolve
({
data
:
{
...
...
@@ -209,10 +205,7 @@ describe('Issuable output', () => {
vm
.
updateIssuable
();
setTimeout
(()
=>
{
expect
(
urlUtils
.
visitUrl
,
).
toHaveBeenCalledWith
(
'
/testing-issue-move
'
);
expect
(
visitUrl
).
toHaveBeenCalledWith
(
'
/testing-issue-move
'
);
done
();
});
});
...
...
@@ -340,7 +333,7 @@ describe('Issuable output', () => {
describe
(
'
deleteIssuable
'
,
()
=>
{
it
(
'
changes URL when deleted
'
,
(
done
)
=>
{
spyOn
(
urlUtils
,
'
visitUrl
'
);
const
visitUrl
=
spyOnDependency
(
issuableApp
,
'
visitUrl
'
);
spyOn
(
vm
.
service
,
'
deleteIssuable
'
).
and
.
callFake
(()
=>
new
Promise
((
resolve
)
=>
{
resolve
({
data
:
{
...
...
@@ -352,16 +345,13 @@ describe('Issuable output', () => {
vm
.
deleteIssuable
();
setTimeout
(()
=>
{
expect
(
urlUtils
.
visitUrl
,
).
toHaveBeenCalledWith
(
'
/test
'
);
expect
(
visitUrl
).
toHaveBeenCalledWith
(
'
/test
'
);
done
();
});
});
it
(
'
stops polling when deleting
'
,
(
done
)
=>
{
spyOn
(
urlUtils
,
'
visitUrl
'
);
spyOn
Dependency
(
issuableApp
,
'
visitUrl
'
);
spyOn
(
vm
.
poll
,
'
stop
'
).
and
.
callThrough
();
spyOn
(
vm
.
service
,
'
deleteIssuable
'
).
and
.
callFake
(()
=>
new
Promise
((
resolve
)
=>
{
resolve
({
...
...
@@ -377,7 +367,6 @@ describe('Issuable output', () => {
expect
(
vm
.
poll
.
stop
,
).
toHaveBeenCalledWith
();
done
();
});
});
...
...
spec/javascripts/issue_show/components/description_spec.js
View file @
4d828eae
import
$
from
'
jquery
'
;
import
Vue
from
'
vue
'
;
import
descriptionComponent
from
'
~/issue_show/components/description.vue
'
;
import
*
as
taskList
from
'
~/task_list
'
;
import
Description
from
'
~/issue_show/components/description.vue
'
;
import
mountComponent
from
'
spec/helpers/vue_mount_component_helper
'
;
describe
(
'
Description component
'
,
()
=>
{
...
...
@@ -17,7 +16,7 @@ describe('Description component', () => {
};
beforeEach
(()
=>
{
DescriptionComponent
=
Vue
.
extend
(
descriptionComponent
);
DescriptionComponent
=
Vue
.
extend
(
Description
);
if
(
!
document
.
querySelector
(
'
.issuable-meta
'
))
{
const
metaData
=
document
.
createElement
(
'
div
'
);
...
...
@@ -82,18 +81,20 @@ describe('Description component', () => {
});
describe
(
'
TaskList
'
,
()
=>
{
let
TaskList
;
beforeEach
(()
=>
{
vm
=
mountComponent
(
DescriptionComponent
,
Object
.
assign
({},
props
,
{
issuableType
:
'
issuableType
'
,
}));
spyOn
(
taskList
,
'
defaul
t
'
);
TaskList
=
spyOnDependency
(
Description
,
'
TaskLis
t
'
);
});
it
(
'
re-inits the TaskList when description changed
'
,
(
done
)
=>
{
vm
.
descriptionHtml
=
'
changed
'
;
setTimeout
(()
=>
{
expect
(
taskList
.
defaul
t
).
toHaveBeenCalled
();
expect
(
TaskLis
t
).
toHaveBeenCalled
();
done
();
});
});
...
...
@@ -103,7 +104,7 @@ describe('Description component', () => {
vm
.
descriptionHtml
=
'
changed
'
;
setTimeout
(()
=>
{
expect
(
taskList
.
defaul
t
).
not
.
toHaveBeenCalled
();
expect
(
TaskLis
t
).
not
.
toHaveBeenCalled
();
done
();
});
});
...
...
@@ -112,7 +113,7 @@ describe('Description component', () => {
vm
.
descriptionHtml
=
'
changed
'
;
setTimeout
(()
=>
{
expect
(
taskList
.
defaul
t
).
toHaveBeenCalledWith
({
expect
(
TaskLis
t
).
toHaveBeenCalledWith
({
dataType
:
'
issuableType
'
,
fieldName
:
'
description
'
,
selector
:
'
.detail-page-description
'
,
...
...
spec/javascripts/shortcuts_dashboard_navigation_spec.js
View file @
4d828eae
import
findAndFollowLink
from
'
~/shortcuts_dashboard_navigation
'
;
import
*
as
urlUtility
from
'
~/lib/utils/url_utility
'
;
describe
(
'
findAndFollowLink
'
,
()
=>
{
it
(
'
visits a link when the selector exists
'
,
()
=>
{
const
href
=
'
/some/path
'
;
const
locationSpy
=
spyOn
(
urlUtility
,
'
visitUrl
'
);
const
visitUrl
=
spyOnDependency
(
findAndFollowLink
,
'
visitUrl
'
);
setFixtures
(
`<a class="my-shortcut" href="
${
href
}
">link</a>`
);
findAndFollowLink
(
'
.my-shortcut
'
);
expect
(
locationSpy
).
toHaveBeenCalledWith
(
href
);
expect
(
visitUrl
).
toHaveBeenCalledWith
(
href
);
});
it
(
'
does not throw an exception when the selector does not exist
'
,
()
=>
{
const
locationSpy
=
spyOn
(
urlUtility
,
'
visitUrl
'
);
const
visitUrl
=
spyOnDependency
(
findAndFollowLink
,
'
visitUrl
'
);
// this should not throw an exception
findAndFollowLink
(
'
.this-selector-does-not-exist
'
);
expect
(
locationSpy
).
not
.
toHaveBeenCalled
();
expect
(
visitUrl
).
not
.
toHaveBeenCalled
();
});
});
spec/javascripts/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js
View file @
4d828eae
import
Vue
from
'
vue
'
;
import
ReadyToMerge
from
'
~/vue_merge_request_widget/components/states/ready_to_merge.vue
'
;
import
eventHub
from
'
~/vue_merge_request_widget/event_hub
'
;
import
*
as
simplePoll
from
'
~/lib/utils/simple_poll
'
;
const
commitMessage
=
'
This is the commit message
'
;
const
commitMessageWithDescription
=
'
This is the commit message description
'
;
...
...
@@ -355,9 +354,9 @@ describe('ReadyToMerge', () => {
describe
(
'
initiateMergePolling
'
,
()
=>
{
it
(
'
should call simplePoll
'
,
()
=>
{
spyOn
(
simplePoll
,
'
default
'
);
const
simplePoll
=
spyOnDependency
(
ReadyToMerge
,
'
simplePoll
'
);
vm
.
initiateMergePolling
();
expect
(
simplePoll
.
default
).
toHaveBeenCalled
();
expect
(
simplePoll
).
toHaveBeenCalled
();
});
});
...
...
@@ -457,11 +456,11 @@ describe('ReadyToMerge', () => {
describe
(
'
initiateRemoveSourceBranchPolling
'
,
()
=>
{
it
(
'
should emit event and call simplePoll
'
,
()
=>
{
spyOn
(
eventHub
,
'
$emit
'
);
spyOn
(
simplePoll
,
'
default
'
);
const
simplePoll
=
spyOnDependency
(
ReadyToMerge
,
'
simplePoll
'
);
vm
.
initiateRemoveSourceBranchPolling
();
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
'
SetBranchRemoveFlag
'
,
[
true
]);
expect
(
simplePoll
.
default
).
toHaveBeenCalled
();
expect
(
simplePoll
).
toHaveBeenCalled
();
});
});
...
...
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