2020-08-01 03:43:15 +02:00
|
|
|
"use strict";
|
|
|
|
|
2020-07-23 22:57:17 +02:00
|
|
|
/*
|
|
|
|
This whole module is dedicated to adding
|
|
|
|
one line of coverage for markdown.js.
|
|
|
|
|
|
|
|
There may be a better way.
|
|
|
|
*/
|
|
|
|
|
2020-07-23 22:41:45 +02:00
|
|
|
const rewiremock = require("rewiremock/node");
|
|
|
|
|
2020-12-01 00:02:16 +01:00
|
|
|
const {set_global, zrequire} = require("../zjsunit/namespace");
|
2020-12-01 00:39:47 +01:00
|
|
|
const {run_test} = require("../zjsunit/test");
|
2020-12-01 00:02:16 +01:00
|
|
|
|
2020-07-23 22:57:17 +02:00
|
|
|
set_global("page_params", {});
|
2021-02-24 22:31:50 +01:00
|
|
|
rewiremock("katex").with({
|
|
|
|
renderToString: () => {
|
|
|
|
throw new Error("some-exception");
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
rewiremock.enable();
|
2020-07-23 22:57:17 +02:00
|
|
|
|
2020-12-01 23:21:38 +01:00
|
|
|
const markdown_config = zrequire("markdown_config");
|
2020-07-23 22:57:17 +02:00
|
|
|
zrequire("hash_util");
|
|
|
|
zrequire("message_store");
|
|
|
|
zrequire("stream_data");
|
|
|
|
zrequire("user_groups");
|
|
|
|
|
2021-02-24 22:31:50 +01:00
|
|
|
const markdown = zrequire("markdown");
|
2020-07-23 22:57:17 +02:00
|
|
|
|
|
|
|
markdown.initialize([], markdown_config.get_helpers());
|
|
|
|
|
|
|
|
run_test("katex_throws_unexpected_exceptions", () => {
|
|
|
|
blueslip.expect("error", "Error: some-exception");
|
|
|
|
const message = {raw_content: "$$a$$"};
|
|
|
|
markdown.apply_markdown(message);
|
|
|
|
});
|
2021-02-24 22:31:50 +01:00
|
|
|
|
|
|
|
rewiremock.disable();
|