about summary refs log tree commit homepage
path: root/t/view.t
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2014-02-25 03:01:04 +0000
committerEric Wong <normalperson@yhbt.net>2014-02-25 03:31:25 +0000
commit25cc5a69a4a38076ea9e587dfa75165fef2273da (patch)
tree5a799335ca505f4ec72431e4497b0ab10c7ff872 /t/view.t
parent858f0a2960123d6d2cbced1bb18e4e5e524df21e (diff)
downloadpublic-inbox-25cc5a69a4a38076ea9e587dfa75165fef2273da.tar.gz
This is to keep content accessible to search engines.
Diffstat (limited to 't/view.t')
-rw-r--r--t/view.t55
1 files changed, 55 insertions, 0 deletions
diff --git a/t/view.t b/t/view.t
new file mode 100644
index 00000000..93372d16
--- /dev/null
+++ b/t/view.t
@@ -0,0 +1,55 @@
+# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors
+# License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
+use strict;
+use warnings;
+use Test::More;
+use Email::MIME;
+use PublicInbox::View;
+
+# plain text
+{
+        my $s = Email::Simple->create(
+                header => [
+                        From => 'a@example.com',
+                        To => 'b@example.com',
+                        'Content-Type' => 'text/plain',
+                        'Message-ID' => '<hello@example.com>',
+                        Subject => 'this is a subject',
+                ],
+                body => "hello world\n",
+        );
+        $s = Email::MIME->new($s->as_string);
+        my $html = PublicInbox::View->as_html($s);
+
+        # ghetto
+        like($html, qr/<a href="hello%40/s, "MID link present");
+        like($html, qr/hello world\b/, "body present");
+}
+
+# multipart crap
+{
+        my $parts = [
+                Email::MIME->create(
+                        attributes => { content_type => 'text/plain', },
+                        body => 'hi',
+                ),
+                Email::MIME->create(
+                        attributes => { content_type => 'text/plain', },
+                        body => 'bye',
+                )
+        ];
+        my $mime = Email::MIME->create(
+                header_str => [
+                        From => 'a@example.com',
+                        Subject => 'blargh',
+                        'Message-ID' => '<blah@xeample.com>',
+                        'In-Reply-To' => '<irp@xeample.com>',
+                        ],
+                parts => $parts,
+        );
+
+        my $html = PublicInbox::View->as_html($mime);
+        print $html;
+}
+
+done_testing();