Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F85831966
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/test/bbcode/generator_test.exs b/test/bbcode/generator_test.exs
new file mode 100644
index 0000000..0ed3f6b
--- /dev/null
+++ b/test/bbcode/generator_test.exs
@@ -0,0 +1,97 @@
+defmodule BBCode.Generator.Test do
+ use ExUnit.Case
+
+ describe "simple tags" do
+ test "[b] tags are translated to <strong>" do
+ assert {:ok, "<strong>testing</strong>"} = BBCode.to_html("[b]testing[/b]")
+ end
+
+ test "[i] tags are translated to <em>" do
+ assert {:ok, "<em>testing</em>"} = BBCode.to_html("[i]testing[/i]")
+ end
+
+ test "[u] tags are translated to <u>" do
+ assert {:ok, "<u>testing</u>"} = BBCode.to_html("[u]testing[/u]")
+ end
+
+ test "[s] tags are translated to <s>" do
+ assert {:ok, "<s>testing</s>"} = BBCode.to_html("[s]testing[/s]")
+ end
+
+ test "[code] tags are translated to <pre>" do
+ assert {:ok, "<pre>testing</pre>"} = BBCode.to_html("[code]testing[/code]")
+ end
+
+ test "[quote] tags are translated to <blockquote>" do
+ assert {:ok, "<blockquote>testing</blockquote>"} = BBCode.to_html("[quote]testing[/quote]")
+ end
+
+ test "compounding simple tags works as expected" do
+ assert {:ok, "<strong><em>testing</em></strong>"} = BBCode.to_html("[b][i]testing[/i][/b]")
+ end
+ end
+
+ describe "lists" do
+ test "[ul] lists are rendered properly" do
+ data = """
+ [ul]
+ [*]a
+ [*]b
+ [*]c
+ [/ul]
+ """
+
+ expected = """
+ <ul>
+ <li>a</li><li>b</li><li>c</li></ul>
+ """
+
+ assert {:ok, ^expected} = BBCode.to_html(data)
+ end
+
+ test "[ol] lists are rendered properly" do
+ data = """
+ [ol]
+ [*]a
+ [*]b
+ [*]c
+ [/ol]
+ """
+
+ expected = """
+ <ol>
+ <li>a</li><li>b</li><li>c</li></ol>
+ """
+
+ assert {:ok, ^expected} = BBCode.to_html(data)
+ end
+ end
+
+ describe "tables" do
+ test "[table] tables are rendered properly" do
+ data = """
+ [table]
+ [tr]
+ [th]header[/th]
+ [/tr]
+ [tr]
+ [td]cell[/td]
+ [/tr]
+ [/table]
+ """
+
+ expected = """
+ <table>
+ <tr>
+ <th>header</th>
+ </tr>
+ <tr>
+ <td>cell</td>
+ </tr>
+ </table>
+ """
+
+ assert {:ok, ^expected} = BBCode.to_html(data)
+ end
+ end
+end
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Nov 2, 1:12 AM (14 h, 41 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1803481
Default Alt Text
(2 KB)
Attached To
Mode
R10 bbcode
Attached
Detach File
Event Timeline