aboutsummaryrefslogtreecommitdiff
path: root/html2md_test.go
diff options
context:
space:
mode:
authorTong Sun <[email protected]>2023-05-02 12:41:20 -0400
committerTong Sun <[email protected]>2023-05-02 12:43:18 -0400
commitf8e39207b0f4b56d29fa4b0711249462dd84b353 (patch)
tree51eba5d82a0070ca42f30a105337be5765972287 /html2md_test.go
parent- [+] add prop_test.go from jsonfiddle (diff)
downloadhtml2md-f8e39207b0f4b56d29fa4b0711249462dd84b353.tar.xz
html2md-f8e39207b0f4b56d29fa4b0711249462dd84b353.zip
- [#] use real test to replace dummy test
Diffstat (limited to 'html2md_test.go')
-rw-r--r--html2md_test.go59
1 files changed, 59 insertions, 0 deletions
diff --git a/html2md_test.go b/html2md_test.go
new file mode 100644
index 0000000..a9ed5ae
--- /dev/null
+++ b/html2md_test.go
@@ -0,0 +1,59 @@
+package main_test
+
+import (
+ "os"
+ "strings"
+ "testing"
+)
+
+const (
+ cmdTest = "./html2md"
+ dirTest = "."
+
+ boldText = "<strong>Bold Text</strong>"
+ boldEscape = "<strong>option src_ip</strong>"
+)
+
+type testCase struct {
+ name, out, in string
+ args []string
+}
+
+func TestExec(t *testing.T) {
+ testData := []testCase{
+ {
+ "BoldText", "**Bold Text**", boldText, []string{"-i"},
+ },
+ {
+ "BoldText-delimiter", "__Bold Text__", boldText,
+ []string{"-i", "--opt-strong-delimiter", "__"},
+ },
+ {
+ "BoldEscape", "**option src\\_ip**", boldEscape, []string{"-i"},
+ },
+ {
+ "Checkbox", "- [x] Checked!\n- [ ] Check Me!",
+ "<ul><li><input type=checkbox checked>Checked!</li><li><input type=checkbox>Check Me!</li></ul>",
+ []string{"-i", "-G"},
+ },
+ {
+ "PluginStrikethrough", "Only ~~blue ones~~ ~~left~~",
+ "Only <del>blue ones</del> <s> left</s>",
+ []string{"-i", "--plugin-strikethrough"},
+ },
+ // {
+ // "", "", "", []string{"-i"},
+ // },
+ }
+
+ os.Chdir(dirTest)
+
+ t.Logf("\n\n== Testing options and plugins\n\n")
+
+ for _, tc := range testData {
+ r := strings.TrimSpace(testIt(t, tc.name, tc.in, tc.args...))
+ if tc.out != r {
+ t.Errorf(`expected "%s" but got "%s" instead`, tc.out, r)
+ }
+ }
+}