Fixing issue detected by test case.

This commit is contained in:
mike12345567 2021-12-15 12:23:00 +00:00
parent 136fe11354
commit 5c00960ac0
2 changed files with 10 additions and 13 deletions

View File

@ -214,7 +214,7 @@ module RestModule {
if (error) {
throw "Invalid JSON for request body"
}
input.body = object
input.body = string
input.headers["Content-Type"] = "application/json"
break
}

View File

@ -14,6 +14,11 @@ const fetch = require("node-fetch")
const RestIntegration = require("../rest")
const { AuthType } = require("../rest")
const HEADERS = {
"Accept": "application/json",
"Content-Type": "application/json"
}
class TestConfiguration {
constructor(config = {}) {
this.integration = new RestIntegration.integration(config)
@ -35,9 +40,7 @@ describe("REST Integration", () => {
const query = {
path: "api",
queryString: "test=1",
headers: {
Accept: "application/json",
},
headers: HEADERS,
bodyType: "json",
requestBody: JSON.stringify({
name: "test",
@ -47,9 +50,7 @@ describe("REST Integration", () => {
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?test=1`, {
method: "POST",
body: '{"name":"test"}',
headers: {
Accept: "application/json",
},
headers: HEADERS,
})
})
@ -86,9 +87,7 @@ describe("REST Integration", () => {
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?test=1`, {
method: "PUT",
body: '{"name":"test"}',
headers: {
Accept: "application/json",
},
headers: HEADERS,
})
})
@ -107,9 +106,7 @@ describe("REST Integration", () => {
const response = await config.integration.delete(query)
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?test=1`, {
method: "DELETE",
headers: {
Accept: "application/json",
},
headers: HEADERS,
body: '{"name":"test"}',
})
})