all repos — honk @ 454608c14f29a74b2835ce657e08524581247ca6

my fork of honk

markitzero_test.go (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
package main

import (
	"testing"
)

func onetest(t *testing.T, input, output string) {
	result := markitzero(input)
	if result != output {
		t.Errorf("\nexpected:\n%s\noutput:\n%s", output, result)
	}
}

func basictest(t *testing.T) {
	input := `link to https://example.com/ with **bold** text`
	output := `link to <a class="mention u-url" href="https://example.com/">https://example.com/</a> with <b>bold</b> text`
	onetest(t, input, output)
}

func linebreak1(t *testing.T) {
	input := "hello\n> a quote\na comment"
	output := "hello<blockquote>a quote</blockquote><p>a comment"
	onetest(t, input, output)
}

func linebreak2(t *testing.T) {
	input := "hello\n\n> a quote\n\na comment"
	output := "hello<br><blockquote>a quote</blockquote><p>a comment"
	onetest(t, input, output)
}

func linebreak3(t *testing.T) {
	input := "hello\n\n```\nfunc(s string)\n```\n\ndoes it go?"
	output := "hello<br><pre><code>func(s string)</code></pre><p>does it go?"
	onetest(t, input, output)
}

func TestMarkitzero(t *testing.T) {
	basictest(t)
	linebreak1(t)
	linebreak2(t)
	linebreak3(t)
}