forked from JohannesKaufmann/html-to-markdown
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin_test.go
60 lines (50 loc) · 1.33 KB
/
plugin_test.go
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package plugin
import (
"testing"
"github.com/nehbit/html-to-markdown"
)
func TestStrikethroughDefault(t *testing.T) {
conv := md.NewConverter("", true, nil)
conv.Use(Strikethrough(""))
input := `<p>Strikethrough uses two tildes. <del>Scratch this.</del></p>`
expected := `Strikethrough uses two tildes. ~Scratch this.~`
markdown, err := conv.ConvertString(input)
if err != nil {
t.Error(err)
}
if markdown != expected {
t.Errorf("got '%s' but wanted '%s'", markdown, expected)
}
}
func TestStrikethrough(t *testing.T) {
conv := md.NewConverter("", true, nil)
conv.Use(Strikethrough("~~"))
input := `<p>Strikethrough uses two tildes. <del>Scratch this.</del></p>`
expected := `Strikethrough uses two tildes. ~~Scratch this.~~`
markdown, err := conv.ConvertString(input)
if err != nil {
t.Error(err)
}
if markdown != expected {
t.Errorf("got '%s' but wanted '%s'", markdown, expected)
}
}
func TestTaskListItems(t *testing.T) {
conv := md.NewConverter("", true, nil)
conv.Use(TaskListItems())
input := `
<ul>
<li><input type=checkbox checked>Checked!</li>
<li><input type=checkbox>Check Me!</li>
</ul>
`
expected := `- [x] Checked!
- [ ] Check Me!`
markdown, err := conv.ConvertString(input)
if err != nil {
t.Error(err)
}
if markdown != expected {
t.Errorf("got '%s' but wanted '%s'", markdown, expected)
}
}