Files
zulip/frontend_tests/node_tests/markdown_katex.js
Anders Kaseorg 6ec808b8df js: Add "use strict" directive to CommonJS files.
ES and TypeScript modules are strict by default and don’t need this
directive.  ESLint will remind us to add it to new CommonJS files and
remove it from ES and TypeScript modules.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-31 22:09:46 -07:00

37 lines
848 B
JavaScript

"use strict";
/*
This whole module is dedicated to adding
one line of coverage for markdown.js.
There may be a better way.
*/
const rewiremock = require("rewiremock/node");
const markdown_config = zrequire("markdown_config");
set_global("page_params", {});
zrequire("hash_util");
zrequire("message_store");
zrequire("people");
zrequire("stream_data");
zrequire("user_groups");
const markdown = rewiremock.proxy(() => zrequire("markdown"), {
"katex/dist/katex.min.js": {
renderToString: () => {
throw new Error("some-exception");
},
},
});
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);
});