fixed .send binding tests
This commit is contained in:
parent
2d1ad16b4f
commit
3eaa3ca1b5
|
@ -923,16 +923,6 @@ func TestHttpClientBindsSend(t *testing.T) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
let testErr;
|
|
||||||
try {
|
|
||||||
$http.send({ url: testUrl + "?testError=1" })
|
|
||||||
} catch (err) {
|
|
||||||
testErr = err
|
|
||||||
}
|
|
||||||
if (!testErr) {
|
|
||||||
throw new Error("Expected an error")
|
|
||||||
}
|
|
||||||
|
|
||||||
let testTimeout;
|
let testTimeout;
|
||||||
try {
|
try {
|
||||||
$http.send({
|
$http.send({
|
||||||
|
@ -946,34 +936,44 @@ func TestHttpClientBindsSend(t *testing.T) {
|
||||||
throw new Error("Expected timeout error")
|
throw new Error("Expected timeout error")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// error response check
|
||||||
|
const test0 = $http.send({
|
||||||
|
url: testUrl + "?testError=1",
|
||||||
|
})
|
||||||
|
|
||||||
// basic fields check
|
// basic fields check
|
||||||
const test1 = $http.send({
|
const test1 = $http.send({
|
||||||
method: "post",
|
method: "post",
|
||||||
url: testUrl,
|
url: testUrl,
|
||||||
data: {"data": "example"},
|
data: {"data": "example"},
|
||||||
headers: {"header1": "123", "header2": "456"}
|
headers: {"header1": "123", "header2": "456"},
|
||||||
})
|
})
|
||||||
|
|
||||||
// with custom content-type header
|
// with custom content-type header
|
||||||
const test2 = $http.send({
|
const test2 = $http.send({
|
||||||
url: testUrl,
|
url: testUrl,
|
||||||
headers: {"content-type": "text/plain"}
|
headers: {"content-type": "text/plain"},
|
||||||
})
|
})
|
||||||
|
|
||||||
const scenarios = [
|
const scenarios = [
|
||||||
|
[test0, {
|
||||||
|
"statusCode": "400",
|
||||||
|
}],
|
||||||
[test1, {
|
[test1, {
|
||||||
|
"statusCode": "200",
|
||||||
"json.method": "POST",
|
"json.method": "POST",
|
||||||
"json.headers.header1": "123",
|
"json.headers.header1": "123",
|
||||||
"json.headers.header2": "456",
|
"json.headers.header2": "456",
|
||||||
"json.headers.content_type": "application/json", // default
|
"json.headers.content_type": "application/json", // default
|
||||||
}],
|
}],
|
||||||
[test2, {
|
[test2, {
|
||||||
|
"statusCode": "200",
|
||||||
"json.method": "GET",
|
"json.method": "GET",
|
||||||
"json.headers.content_type": "text/plain",
|
"json.headers.content_type": "text/plain",
|
||||||
}],
|
}],
|
||||||
]
|
]
|
||||||
|
|
||||||
for (let scenario in scenarios) {
|
for (let scenario of scenarios) {
|
||||||
const result = scenario[0];
|
const result = scenario[0];
|
||||||
const expectations = scenario[1];
|
const expectations = scenario[1];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue