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
Boxiang Sun
gitlab-ce
Commits
8a713b37
Commit
8a713b37
authored
Mar 30, 2018
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add spyOnDependency method
parent
8166a11c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
7 deletions
+18
-7
spec/javascripts/.eslintrc
spec/javascripts/.eslintrc
+1
-0
spec/javascripts/pages/admin/jobs/index/components/stop_jobs_modal_spec.js
...pages/admin/jobs/index/components/stop_jobs_modal_spec.js
+2
-3
spec/javascripts/pages/milestones/shared/components/delete_milestone_modal_spec.js
...lestones/shared/components/delete_milestone_modal_spec.js
+2
-3
spec/javascripts/test_bundle.js
spec/javascripts/test_bundle.js
+13
-1
No files found.
spec/javascripts/.eslintrc
View file @
8a713b37
...
...
@@ -18,6 +18,7 @@
"sandbox": false,
"setFixtures": false,
"setStyleFixtures": false,
"spyOnDependency": false,
"spyOnEvent": false,
"ClassSpecHelper": false
},
...
...
spec/javascripts/pages/admin/jobs/index/components/stop_jobs_modal_spec.js
View file @
8a713b37
...
...
@@ -2,7 +2,6 @@ import Vue from 'vue';
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
stopJobsModal
from
'
~/pages/admin/jobs/index/components/stop_jobs_modal.vue
'
;
import
*
as
urlUtility
from
'
~/lib/utils/url_utility
'
;
import
mountComponent
from
'
spec/helpers/vue_mount_component_helper
'
;
...
...
@@ -24,7 +23,7 @@ describe('stop_jobs_modal.vue', () => {
describe
(
'
onSubmit
'
,
()
=>
{
it
(
'
stops jobs and redirects to overview page
'
,
(
done
)
=>
{
const
responseURL
=
`
${
gl
.
TEST_HOST
}
/stop_jobs_modal.vue/jobs`
;
const
redirectSpy
=
spyOn
(
urlUtility
,
'
redirectTo
'
);
const
redirectSpy
=
spyOn
Dependency
(
stopJobsModal
,
'
redirectTo
'
);
spyOn
(
axios
,
'
post
'
).
and
.
callFake
((
url
)
=>
{
expect
(
url
).
toBe
(
props
.
url
);
return
Promise
.
resolve
({
...
...
@@ -44,7 +43,7 @@ describe('stop_jobs_modal.vue', () => {
it
(
'
displays error if stopping jobs failed
'
,
(
done
)
=>
{
const
dummyError
=
new
Error
(
'
stopping jobs failed
'
);
const
redirectSpy
=
spyOn
(
urlUtility
,
'
redirectTo
'
);
const
redirectSpy
=
spyOn
Dependency
(
stopJobsModal
,
'
redirectTo
'
);
spyOn
(
axios
,
'
post
'
).
and
.
callFake
((
url
)
=>
{
expect
(
url
).
toBe
(
props
.
url
);
return
Promise
.
reject
(
dummyError
);
...
...
spec/javascripts/pages/milestones/shared/components/delete_milestone_modal_spec.js
View file @
8a713b37
...
...
@@ -3,7 +3,6 @@ import Vue from 'vue';
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
deleteMilestoneModal
from
'
~/pages/milestones/shared/components/delete_milestone_modal.vue
'
;
import
eventHub
from
'
~/pages/milestones/shared/event_hub
'
;
import
*
as
urlUtility
from
'
~/lib/utils/url_utility
'
;
import
mountComponent
from
'
spec/helpers/vue_mount_component_helper
'
;
...
...
@@ -40,7 +39,7 @@ describe('delete_milestone_modal.vue', () => {
},
});
});
const
redirectSpy
=
spyOn
(
urlUtility
,
'
redirectTo
'
);
const
redirectSpy
=
spyOn
Dependency
(
deleteMilestoneModal
,
'
redirectTo
'
);
vm
.
onSubmit
()
.
then
(()
=>
{
...
...
@@ -60,7 +59,7 @@ describe('delete_milestone_modal.vue', () => {
eventHub
.
$emit
.
calls
.
reset
();
return
Promise
.
reject
(
dummyError
);
});
const
redirectSpy
=
spyOn
(
urlUtility
,
'
redirectTo
'
);
const
redirectSpy
=
spyOn
Dependency
(
deleteMilestoneModal
,
'
redirectTo
'
);
vm
.
onSubmit
()
.
catch
((
error
)
=>
{
...
...
spec/javascripts/test_bundle.js
View file @
8a713b37
/* eslint-disable jasmine/no-global-setup */
/* eslint-disable jasmine/no-global-setup, jasmine/no-unsafe-spy, no-underscore-dangle */
import
$
from
'
jquery
'
;
import
'
vendor/jasmine-jquery
'
;
import
'
~/commons
'
;
...
...
@@ -55,6 +56,17 @@ window.addEventListener('unhandledrejection', event => {
console
.
error
(
event
.
reason
.
stack
||
event
.
reason
);
});
// Add global function to spy on a module's dependencies via rewire
window
.
spyOnDependency
=
(
module
,
name
)
=>
{
const
dependency
=
module
.
__GetDependency__
(
name
);
const
spy
=
jasmine
.
createSpy
(
name
,
dependency
);
module
.
__Rewire__
(
name
,
spy
);
return
spy
;
};
// Reset any rewired modules after each test (see babel-plugin-rewire)
afterEach
(
__rewire_reset_all__
);
// eslint-disable-line
// HACK: Chrome 59 disconnects if there are too many synchronous tests in a row
// because it appears to lock up the thread that communicates to Karma's socket
// This async beforeEach gets called on every spec and releases the JS thread long
...
...
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