all repos — honk @ 73ad26f01d1da2b0c0d5745294b003ef9e2eac0d

my fork of honk

markitzero_test.go (view raw)

 1package main
 2
 3import (
 4	"testing"
 5)
 6
 7func doonezerotest(t *testing.T, input, output string) {
 8	result := markitzero(input)
 9	if result != output {
10		t.Errorf("\nexpected:\n%s\noutput:\n%s", output, result)
11	}
12}
13
14func TestBasictest(t *testing.T) {
15	input := `link to https://example.com/ with **bold** text`
16	output := `link to <a class="mention u-url" href="https://example.com/">https://example.com/</a> with <b>bold</b> text`
17	doonezerotest(t, input, output)
18}
19
20func TestLinebreak1(t *testing.T) {
21	input := "hello\n> a quote\na comment"
22	output := "hello<blockquote>a quote</blockquote><p>a comment"
23	doonezerotest(t, input, output)
24}
25
26func TestLinebreak2(t *testing.T) {
27	input := "hello\n\n> a quote\n\na comment"
28	output := "hello<br><blockquote>a quote</blockquote><p>a comment"
29	doonezerotest(t, input, output)
30}
31
32func TestLinebreak3(t *testing.T) {
33	input := "hello\n\n```\nfunc(s string)\n```\n\ndoes it go?"
34	output := "hello<br><pre><code>func(s string)</code></pre><p>does it go?"
35	doonezerotest(t, input, output)
36}
37
38func TestCodeStyles(t *testing.T) {
39	input := "hello\n\n```go\nfunc(s string)\n```\n\ndoes it go?"
40	output := "hello<br><pre><code><span class=kw>func</span><span class=op>(</span>s <span class=tp>string</span><span class=op>)</span></code></pre><p>does it go?"
41	doonezerotest(t, input, output)
42}
43
44func TestSimplelink(t *testing.T) {
45	input := "This is a [link](https://example.com)."
46	output := `This is a <a class="mention u-url" href="https://example.com">link</a>.`
47	doonezerotest(t, input, output)
48}
49
50func TestSimplelink2(t *testing.T) {
51	input := "See (http://example.com) for examples."
52	output := `See (<a class="mention u-url" href="http://example.com">http://example.com</a>) for examples.`
53	doonezerotest(t, input, output)
54}
55
56func TestWikilink(t *testing.T) {
57	input := "I watched [Hackers](https://en.wikipedia.org/wiki/Hackers_(film))"
58	output := `I watched <a class="mention u-url" href="https://en.wikipedia.org/wiki/Hackers_(film)">Hackers</a>`
59	doonezerotest(t, input, output)
60}
61
62func TestQuotedlink(t *testing.T) {
63	input := `quoted "https://example.com/link" here`
64	output := `quoted "<a class="mention u-url" href="https://example.com/link">https://example.com/link</a>" here`
65	doonezerotest(t, input, output)
66}
67
68func TestHonklink(t *testing.T) {
69	input := `https://en.wikipedia.org/wiki/Honk!`
70	output := `<a class="mention u-url" href="https://en.wikipedia.org/wiki/Honk!">https://en.wikipedia.org/wiki/Honk!</a>`
71	doonezerotest(t, input, output)
72}
73