"use strict"; const assert = require("node:assert/strict"); const {mock_esm, zrequire} = require("./lib/namespace.cjs"); const {run_test} = require("./lib/test.cjs"); const thumbnail = mock_esm("../src/thumbnail"); const {postprocess_content} = zrequire("postprocess_content"); const {initialize_user_settings} = zrequire("user_settings"); const user_settings = {}; initialize_user_settings({user_settings}); run_test("postprocess_content", () => { assert.equal( postprocess_content( 'good ' + 'upload ' + 'invalid ' + 'unsafe ' + 'fragment' + '
", ), 'good ' + 'upload ' + "invalid " + "unsafe " + 'fragment' + ' ", ); }); run_test("message_inline_animated_image_still", ({override}) => { const thumbnail_formats = [ { name: "840x560-anim.webp", max_width: 840, max_height: 560, format: "webp", animated: true, }, { name: "840x560.webp", max_width: 840, max_height: 560, format: "webp", animated: false, }, { name: "300x200-anim.webp", max_width: 300, max_height: 200, format: "webp", animated: true, }, { name: "300x200.webp", max_width: 300, max_height: 200, format: "webp", animated: false, }, { name: "300x200.jpg", max_width: 300, max_height: 200, format: "jpg", animated: false, }, ]; // TODO: Initialize the real thumbnail.ts rather than mocking it. override(thumbnail, "preferred_format", thumbnail_formats[3]); override(thumbnail, "animated_format", thumbnail_formats[2]); assert.equal( postprocess_content( ' ", ), ' ", ); // Now verify the behavior for animated images. override(user_settings, "web_animate_image_previews", "always"); assert.equal( postprocess_content( ' ", ), ' ", ); // And verify the different behavior for other values of the animation setting. override(user_settings, "web_animate_image_previews", "on_hover"); assert.equal( postprocess_content( ' ", ), ' ", ); override(user_settings, "web_animate_image_previews", "never"); assert.equal( postprocess_content( ' ", ), ' ", ); });