Fixing issue detected by test case.
This commit is contained in:
parent
ce1b40aa7a
commit
06490c5fa6
|
@ -214,7 +214,7 @@ module RestModule {
|
||||||
if (error) {
|
if (error) {
|
||||||
throw "Invalid JSON for request body"
|
throw "Invalid JSON for request body"
|
||||||
}
|
}
|
||||||
input.body = object
|
input.body = string
|
||||||
input.headers["Content-Type"] = "application/json"
|
input.headers["Content-Type"] = "application/json"
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,11 @@ const fetch = require("node-fetch")
|
||||||
const RestIntegration = require("../rest")
|
const RestIntegration = require("../rest")
|
||||||
const { AuthType } = require("../rest")
|
const { AuthType } = require("../rest")
|
||||||
|
|
||||||
|
const HEADERS = {
|
||||||
|
"Accept": "application/json",
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
}
|
||||||
|
|
||||||
class TestConfiguration {
|
class TestConfiguration {
|
||||||
constructor(config = {}) {
|
constructor(config = {}) {
|
||||||
this.integration = new RestIntegration.integration(config)
|
this.integration = new RestIntegration.integration(config)
|
||||||
|
@ -35,9 +40,7 @@ describe("REST Integration", () => {
|
||||||
const query = {
|
const query = {
|
||||||
path: "api",
|
path: "api",
|
||||||
queryString: "test=1",
|
queryString: "test=1",
|
||||||
headers: {
|
headers: HEADERS,
|
||||||
Accept: "application/json",
|
|
||||||
},
|
|
||||||
bodyType: "json",
|
bodyType: "json",
|
||||||
requestBody: JSON.stringify({
|
requestBody: JSON.stringify({
|
||||||
name: "test",
|
name: "test",
|
||||||
|
@ -47,9 +50,7 @@ describe("REST Integration", () => {
|
||||||
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?test=1`, {
|
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?test=1`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: '{"name":"test"}',
|
body: '{"name":"test"}',
|
||||||
headers: {
|
headers: HEADERS,
|
||||||
Accept: "application/json",
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -86,9 +87,7 @@ describe("REST Integration", () => {
|
||||||
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?test=1`, {
|
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?test=1`, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
body: '{"name":"test"}',
|
body: '{"name":"test"}',
|
||||||
headers: {
|
headers: HEADERS,
|
||||||
Accept: "application/json",
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -107,9 +106,7 @@ describe("REST Integration", () => {
|
||||||
const response = await config.integration.delete(query)
|
const response = await config.integration.delete(query)
|
||||||
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?test=1`, {
|
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?test=1`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
headers: {
|
headers: HEADERS,
|
||||||
Accept: "application/json",
|
|
||||||
},
|
|
||||||
body: '{"name":"test"}',
|
body: '{"name":"test"}',
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue