BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
ab6f4ad4
Commit
ab6f4ad4
authored
Jan 26, 2018
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'winh-check-axios-restore' into 'master'
Make sure that axios adapater is restored after mocking See merge request gitlab-org/gitlab-ce!16660
parents
b8d044af
d82e709f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
0 deletions
+18
-0
axios_utils.js
app/assets/javascripts/lib/utils/axios_utils.js
+8
-0
test_bundle.js
spec/javascripts/test_bundle.js
+10
-0
No files found.
app/assets/javascripts/lib/utils/axios_utils.js
View file @
ab6f4ad4
...
...
@@ -22,3 +22,11 @@ axios.interceptors.response.use((config) => {
});
export
default
axios
;
/**
* @return The adapter that axios uses for dispatching requests. This may be overwritten in tests.
*
* @see https://github.com/axios/axios/tree/master/lib/adapters
* @see https://github.com/ctimmerm/axios-mock-adapter/blob/v1.12.0/src/index.js#L39
*/
export
const
getDefaultAdapter
=
()
=>
axios
.
defaults
.
adapter
;
spec/javascripts/test_bundle.js
View file @
ab6f4ad4
...
...
@@ -6,6 +6,8 @@ import '~/commons';
import
Vue
from
'vue'
;
import
VueResource
from
'vue-resource'
;
import
{
getDefaultAdapter
}
from
'~/lib/utils/axios_utils'
;
const
isHeadlessChrome
=
/
\b
HeadlessChrome
\/
/
.
test
(
navigator
.
userAgent
);
Vue
.
config
.
devtools
=
!
isHeadlessChrome
;
Vue
.
config
.
productionTip
=
false
;
...
...
@@ -59,6 +61,8 @@ beforeEach(() => {
Vue
.
http
.
interceptors
=
builtinVueHttpInterceptors
.
slice
();
});
const
axiosDefaultAdapter
=
getDefaultAdapter
();
// render all of our tests
const
testsContext
=
require
.
context
(
'.'
,
true
,
/_spec$/
);
testsContext
.
keys
().
forEach
(
function
(
path
)
{
...
...
@@ -94,6 +98,12 @@ describe('test errors', () => {
it
(
'has no Vue error'
,
()
=>
{
expect
(
hasVueErrors
).
toBe
(
false
);
});
it
(
'restores axios adapter after mocking'
,
()
=>
{
if
(
getDefaultAdapter
()
!==
axiosDefaultAdapter
)
{
fail
(
'axios adapter is not restored! Did you forget a restore() on MockAdapter?'
);
}
});
});
// if we're generating coverage reports, make sure to include all files so
...
...
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