mirror of
https://github.com/zulip/zulip.git
synced 2025-11-18 04:43:58 +00:00
node tests: Test upload.feature_check directly.
This commit is contained in:
committed by
Steve Howell
parent
779f56d411
commit
f6edaaab96
@@ -35,6 +35,19 @@ const plugin_stub = {
|
||||
|
||||
let upload = zrequire("upload");
|
||||
|
||||
run_test("feature_check", (override) => {
|
||||
const upload_button = $.create("upload-button-stub");
|
||||
upload_button.addClass("notdisplayed");
|
||||
upload.feature_check(upload_button);
|
||||
assert(upload_button.hasClass("notdisplayed"));
|
||||
|
||||
override(window, "XMLHttpRequest", function () {
|
||||
return {upload: true};
|
||||
});
|
||||
upload.feature_check(upload_button);
|
||||
assert(!upload_button.hasClass("notdisplayed"));
|
||||
});
|
||||
|
||||
run_test("make_upload_absolute", () => {
|
||||
let uri = "/user_uploads/5/d4/6lSlfIPIg9nDI2Upj0Mq_EbE/kerala.png";
|
||||
const expected_uri = "https://foo.com/user_uploads/5/d4/6lSlfIPIg9nDI2Upj0Mq_EbE/kerala.png";
|
||||
|
||||
@@ -17,7 +17,7 @@ export function make_upload_absolute(uri) {
|
||||
|
||||
// Show the upload button only if the browser supports it.
|
||||
export function feature_check(upload_button) {
|
||||
if (window.XMLHttpRequest && new XMLHttpRequest().upload) {
|
||||
if (window.XMLHttpRequest && new window.XMLHttpRequest().upload) {
|
||||
upload_button.removeClass("notdisplayed");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user