Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

lightbox: Export method for testing purposes.

Steve Howellff3175f8a271
diff --git a/frontend_tests/node_tests/lightbox.js b/frontend_tests/node_tests/lightbox.js
index a857b9e4df1..b4168ddcd5b 100644
--- a/frontend_tests/node_tests/lightbox.js
+++ b/frontend_tests/node_tests/lightbox.js
@@ -48,8 +48,7 @@ run_test("pan_and_zoom", (override) => {
return "message-stub";
};
- // Used by render_lightbox_list_images
- $.stub_selector(".focused_table .message_inline_image img", []);
+ override(lightbox, "render_lightbox_list_images", () => {});
lightbox.open(img);
@@ -84,8 +83,7 @@ run_test("youtube", (override) => {
link.closest = () => msg;
link.attr("href", href);
- // Used by render_lightbox_list_images
- $.stub_selector(".focused_table .message_inline_image img", []);
+ override(lightbox, "render_lightbox_list_images", () => {});
lightbox.open(img);
assert.equal($(".image-actions .open").attr("href"), href);
diff --git a/frontend_tests/zjsunit/zjquery.js b/frontend_tests/zjsunit/zjquery.js
index b57ff0cada1..635bb1825e7 100644
--- a/frontend_tests/zjsunit/zjquery.js
+++ b/frontend_tests/zjsunit/zjquery.js
@@ -531,10 +531,6 @@ function make_zjquery() {
return elem;
};
- zjquery.stub_selector = function (selector, stub) {
- elems.set(selector, stub);
- };
-
zjquery.trim = function (s) {
return s;
};
diff --git a/static/js/lightbox.js b/static/js/lightbox.js
index 7a4ddf9d43c..53089132d88 100644
--- a/static/js/lightbox.js
+++ b/static/js/lightbox.js
@@ -8,7 +8,7 @@ let is_open = false;
// memoized instead of being looked up multiple times.
const asset_map = new Map();
-function render_lightbox_list_images(preview_source) {
+exports.render_lightbox_list_images = function (preview_source) {
if (!is_open) {
const images = Array.prototype.slice.call($(".focused_table .message_inline_image img"));
const $image_list = $("#lightbox_overlay .image-list").html("");
@@ -31,10 +31,10 @@ function render_lightbox_list_images(preview_source) {
exports.parse_image_data(img);
}
}
-}
+};
function display_image(payload) {
- render_lightbox_list_images(payload.preview);
+ exports.render_lightbox_list_images(payload.preview);
$(".player-container").hide();
$(".image-actions, .image-description, .download, .lightbox-canvas-trigger").show();
@@ -62,7 +62,7 @@ function display_image(payload) {
}
function display_video(payload) {
- render_lightbox_list_images(payload.preview);
+ exports.render_lightbox_list_images(payload.preview);
$(
"#lightbox_overlay .image-preview, .image-description, .download, .lightbox-canvas-trigger",