| 1 | package ansi_test |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/charmbracelet/x/ansi" |
| 7 | ) |
| 8 | |
| 9 | func TestNewHyperlink_NoParams(t *testing.T) { |
| 10 | h := ansi.SetHyperlink("https://example.com") |
| 11 | if h != "\x1b]8;;https://example.com\x07" { |
| 12 | t.Errorf("Unexpected hyperlink: %s", h) |
| 13 | } |
| 14 | } |
| 15 | |
| 16 | func TestNewHyperlinkParams(t *testing.T) { |
| 17 | h := ansi.SetHyperlink("https://example.com", "color=blue", "size=12") |
| 18 | if h != "\x1b]8;color=blue:size=12;https://example.com\x07" { |
| 19 | t.Errorf("Unexpected hyperlink: %s", h) |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | func TestHyperlinkReset(t *testing.T) { |
| 24 | h := ansi.SetHyperlink("") |
| 25 | if h != "\x1b]8;;\x07" { |
| 26 | t.Errorf("Unexpected hyperlink: %s", h) |
| 27 | } |
| 28 | } |