Merge branch 'master' into next

This commit is contained in:
Vladimir Gorej
2023-04-26 14:01:09 +02:00
5 changed files with 539 additions and 505 deletions

View File

@@ -39,4 +39,18 @@ describe("<ResponseBody />", function () {
console.warn(wrapper.debug())
expect(wrapper.find("highlightCodeComponent[canCopy]").length).toEqual(1)
})
it("should render Download file link for non-empty response", function () {
props.contentType = "application/octet-stream"
props.content = new Blob(["\"test\""], { type: props.contentType })
const wrapper = shallow(<ResponseBody {...props} />)
expect(wrapper.text()).toMatch(/Download file/)
})
it("should not render Download file link for empty response", function () {
props.contentType = "application/octet-stream"
props.content = new Blob()
const wrapper = shallow(<ResponseBody {...props} />)
expect(wrapper.text()).not.toMatch(/Download file/)
})
})

View File

@@ -29,6 +29,11 @@ function setUpDomEnvironment() {
}
copyProps(win, window) // use UI's built-in window wrapper
copyProps(window, global)
// https://github.com/jsdom/jsdom/issues/1721
if (typeof global.window.URL.createObjectURL === "undefined") {
Object.defineProperty(global.window.URL, "createObjectURL", { value: () => "data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==" })
}
}
setUpDomEnvironment()