"use strict";
const {strict: assert} = require("assert");
const {zrequire} = require("./lib/namespace");
const {run_test} = require("./lib/test");
const {page_params} = require("./lib/zpage_params");
const copy_and_paste = zrequire("copy_and_paste");
run_test("paste_handler_converter", () => {
page_params.development_environment = true;
/*
Pasting from another Zulip message
*/
// Bold text
let input =
' love the Zulip Organization.';
assert.equal(
copy_and_paste.paste_handler_converter(input),
" love the **Zulip** **Organization**.",
);
// Inline code
input =
'The JSDOM
constructor';
assert.equal(copy_and_paste.paste_handler_converter(input), "The `JSDOM` constructor");
// A python code block
input = `
zulip code block in python
print("hello world")
single line
';
assert.equal(copy_and_paste.paste_handler_converter(input), "`single line`");
// Raw links without custom text
input =
'https://zulip.readthedocs.io/en/latest/subsystems/logging.html';
assert.equal(
copy_and_paste.paste_handler_converter(input),
"https://zulip.readthedocs.io/en/latest/subsystems/logging.html",
);
// Links with custom text
input =
'Contributing guide';
assert.equal(
copy_and_paste.paste_handler_converter(input),
"[Contributing guide](https://zulip.readthedocs.io/en/latest/contributing/contributing.html)",
);
// Only numbered list (list style retained)
input =
'normal text
'; assert.equal(copy_and_paste.paste_handler_converter(input), "# Zulip overview\n\nnormal text"); // Only heading (strip heading style) input = 'paragraph 1
paragraph 2
'; assert.equal(copy_and_paste.paste_handler_converter(input), "paragraph 1\n\nparagraph 2"); // Pasting from external sources // Pasting list from GitHub input = '
Test list: