Some fixes for the rest test cases which mocked too widely.
This commit is contained in:
parent
fcb535efee
commit
a8e12dfb6b
2 changed files with 28 additions and 13 deletions
|
@ -4,7 +4,11 @@ jest.mock("node-fetch", () => {
|
||||||
raw: () => {
|
raw: () => {
|
||||||
return { "content-type": ["application/json"] }
|
return { "content-type": ["application/json"] }
|
||||||
},
|
},
|
||||||
get: () => ["application/json"],
|
get: (name: string) => {
|
||||||
|
if (name.toLowerCase() === "content-type") {
|
||||||
|
return ["application/json"]
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
json: jest.fn(() => ({
|
json: jest.fn(() => ({
|
||||||
my_next_cursor: 123,
|
my_next_cursor: 123,
|
||||||
|
@ -211,7 +215,16 @@ describe("REST Integration", () => {
|
||||||
json: json ? async () => json : undefined,
|
json: json ? async () => json : undefined,
|
||||||
text: text ? async () => text : undefined,
|
text: text ? async () => text : undefined,
|
||||||
headers: {
|
headers: {
|
||||||
get: (key: any) => (key === "content-length" ? 100 : header),
|
get: (key: string) => {
|
||||||
|
switch (key.toLowerCase()) {
|
||||||
|
case "content-length":
|
||||||
|
return 100
|
||||||
|
case "content-type":
|
||||||
|
return header
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
},
|
||||||
raw: () => ({ "content-type": header }),
|
raw: () => ({ "content-type": header }),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ export function getAttachmentHeaders(headers: Headers) {
|
||||||
// the API does not follow the requirements of https://www.ietf.org/rfc/rfc2183.txt
|
// the API does not follow the requirements of https://www.ietf.org/rfc/rfc2183.txt
|
||||||
// all content-disposition headers should be format disposition-type; parameters
|
// all content-disposition headers should be format disposition-type; parameters
|
||||||
// but some APIs do not provide a type, causing the parse below to fail - add one to fix this
|
// but some APIs do not provide a type, causing the parse below to fail - add one to fix this
|
||||||
|
if (contentDisposition) {
|
||||||
const quotesRegex = /"(?:[^"\\]|\\.)*"|;/g
|
const quotesRegex = /"(?:[^"\\]|\\.)*"|;/g
|
||||||
let match: RegExpMatchArray | null = null,
|
let match: RegExpMatchArray | null = null,
|
||||||
found = false
|
found = false
|
||||||
|
@ -21,6 +22,7 @@ export function getAttachmentHeaders(headers: Headers) {
|
||||||
contentType,
|
contentType,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return { contentDisposition, contentType }
|
return { contentDisposition, contentType }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue