Commit e033ad6679dcdeee561f55ce9d253e21d8c3f29e

Parents: cd9fcd71c4b679409c51231db5b16cd09171d3d0

From: Moritz Poldrack <git@moritz.sh>
Date: Mon Dec 6 17:01:19 2021 +0700

added tests for hyperlink

		

Stats

hyperlink_test.go +21/-0

Changeset

 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
diff --git a/hyperlink_test.go b/hyperlink_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..06e717f3104c0c718bd7a362b2697f140bf24705
--- /dev/null
+++ b/hyperlink_test.go
@@ -0,0 +1,21 @@
+package ansi
+
+import (
+	"fmt"
+	"net/url"
+	"testing"
+)
+
+func TestLink(t *testing.T) {
+	t.Run("url", func(t *testing.T) {
+		u, _ := url.Parse("https://example.com")
+
+		fmt.Printf("Link to example.com: %s\n", Link(*u, "Linktext"))
+	})
+	t.Run("string", func(t *testing.T) {
+		fmt.Printf("Link to my homepage: %s\n", LinkString("https://moritz.sh", "Linktext"))
+	})
+	t.Run("file", func(t *testing.T) {
+		fmt.Printf("Link to hyperlink_test.go: %s\n", LinkFile("hyperlink_test.go", "Linktext"))
+	})
+}