summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorDylan Hardison <dylan@mozilla.com>2016-05-20 19:46:23 +0200
committerDylan Hardison <dylan@mozilla.com>2016-05-20 19:49:12 +0200
commit34092dea402579148d647d222051a547ab143c53 (patch)
tree4c4d10caddf91b212947dd1414061b35482405f3 /t
parent779e021e3f6ba106cc50522647ce5f921c9c14dd (diff)
downloadbugzilla-34092dea402579148d647d222051a547ab143c53.tar.gz
bugzilla-34092dea402579148d647d222051a547ab143c53.tar.xz
add markdown tests for Bug 1205415
Diffstat (limited to 't')
-rw-r--r--t/100markdown.t59
1 files changed, 59 insertions, 0 deletions
diff --git a/t/100markdown.t b/t/100markdown.t
new file mode 100644
index 000000000..5cc6ecd4e
--- /dev/null
+++ b/t/100markdown.t
@@ -0,0 +1,59 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
+# Enforce high standards against code that will be installed
+
+use 5.14.0;
+use strict;
+use warnings;
+
+use lib qw(. lib local/lib/perl5 t);
+use Test2::Bundle::Extended;
+use Bugzilla;
+use Bugzilla::Bug;
+use Bugzilla::Comment;
+use Bugzilla::User;
+use Bugzilla::Markdown;
+
+my $user_mock = mock 'Bugzilla::User' => (
+ override_constructor => ['new', 'hash'],
+);
+
+my $comment_mock = mock 'Bugzilla::Comment' => (
+ add_constructor => ['new', 'hash'],
+);
+
+my $bug_mock = mock 'Bugzilla::Bug' => (
+ override_constructor => ['new', 'hash'],
+);
+
+# mocked objects just take all constructor args and put them into the hash.
+my $user = Bugzilla::User->new(
+ userid => 33,
+ settings => { use_markdown => { is_enabled => 1, value => 'on' } },
+);
+my $bug = Bugzilla::Bug->new(bug_id => 666);
+my $comment = Bugzilla::Comment->new(already_wrapped => 0);
+
+Bugzilla->set_user($user);
+
+my $markdown_text = <<MARKDOWN;
+```
+this is a block
+> with an embedded blockquote
+```
+MARKDOWN
+
+my $markdown = Bugzilla::Markdown->new();
+
+ok($markdown, "got a new markdown object");
+my $markdown_html = $markdown->markdown($markdown_text, $bug, $comment);
+is("<pre><code>this is a block\n"
+ . "&gt; with an embedded blockquote</code></pre>\n",
+ $markdown_html, "code block with embedded block quote");
+
+done_testing;