Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
minerva
core
Commits
de3a911b
Commit
de3a911b
authored
7 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
mock ServerConnector ignores undefined query params
parent
acb9206b
No related branches found
Branches containing commit
No related tags found
1 merge request
!134
Resolve "uploading of data overlay fails"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend-js/src/test/js/ServerConnector-mock.js
+12
-11
12 additions, 11 deletions
frontend-js/src/test/js/ServerConnector-mock.js
with
12 additions
and
11 deletions
frontend-js/src/test/js/ServerConnector-mock.js
+
12
−
11
View file @
de3a911b
...
...
@@ -17,6 +17,7 @@ var ServerConnectorMock = OriginalServerConnector;
function
replaceAsterisk
(
str
)
{
return
str
.
replace
(
/
\*
/g
,
"
all
"
).
replace
(
/
\:
/g
,
"
.
"
);
}
function
urlToFileName
(
url
)
{
var
result
=
url
;
var
token
=
OriginalServerConnector
.
getSessionData
().
getToken
();
...
...
@@ -32,15 +33,15 @@ function urlToFileName(url) {
function
encodeParams
(
params
)
{
var
result
=
{};
for
(
var
key
in
params
)
{
if
(
params
.
hasOwnProperty
(
key
))
{
for
(
var
key
in
params
)
{
if
(
params
.
hasOwnProperty
(
key
)
&&
params
[
key
]
!==
undefined
)
{
result
[
key
]
=
encodeURIComponent
(
params
[
key
]);
}
}
return
result
;
}
ServerConnectorMock
.
_sendRequest
=
function
(
params
)
{
ServerConnectorMock
.
_sendRequest
=
function
(
params
)
{
var
self
=
this
;
var
url
=
params
.
url
;
var
prefix
=
params
.
method
;
...
...
@@ -56,9 +57,9 @@ ServerConnectorMock._sendRequest = function(params) {
if
(
params
.
json
!==
undefined
)
{
suffix
+=
self
.
createGetParams
(
params
.
json
);
}
return
new
Promise
(
function
(
resolve
,
reject
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
if
(
url
.
indexOf
(
"
http
"
)
===
0
)
{
request
.
get
(
url
,
function
(
error
,
response
,
body
)
{
request
.
get
(
url
,
function
(
error
,
response
,
body
)
{
if
(
error
)
{
reject
(
error
);
}
else
if
(
response
.
statusCode
!==
200
)
{
...
...
@@ -69,12 +70,12 @@ ServerConnectorMock._sendRequest = function(params) {
});
}
else
{
var
fileName
=
urlToFileName
(
url
+
prefix
+
suffix
);
fs
.
readFile
(
fileName
,
'
utf8
'
,
function
(
err
,
content
)
{
fs
.
readFile
(
fileName
,
'
utf8
'
,
function
(
err
,
content
)
{
if
(
err
)
{
reject
(
new
NetworkError
(
err
.
message
,
{
content
:
content
,
url
:
fileName
,
statusCode
:
404
content
:
content
,
url
:
fileName
,
statusCode
:
404
}));
}
else
{
resolve
(
content
);
...
...
@@ -84,13 +85,13 @@ ServerConnectorMock._sendRequest = function(params) {
});
};
ServerConnectorMock
.
getApiBaseUrl
=
function
()
{
ServerConnectorMock
.
getApiBaseUrl
=
function
()
{
return
"
./testFiles/apiCalls/
"
;
};
var
originalGetApiUrl
=
OriginalServerConnector
.
getApiUrl
;
ServerConnectorMock
.
getApiUrl
=
function
(
paramObj
)
{
ServerConnectorMock
.
getApiUrl
=
function
(
paramObj
)
{
// replace '?' with '/'
// the call is done on ServerConnectorObject (so 'this' is set properly)
return
originalGetApiUrl
.
call
(
this
,
paramObj
).
replace
(
/
\?
/g
,
'
/
'
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment