File: hyperlink_test.go

package info (click to toggle)
golang-github-charmbracelet-x 0.0~git20240809.9ab0ca0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,004 kB
  • sloc: sh: 55; makefile: 5
file content (28 lines) | stat: -rw-r--r-- 633 bytes parent folder | download
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
package ansi_test

import (
	"testing"

	"github.com/charmbracelet/x/ansi"
)

func TestNewHyperlink_NoParams(t *testing.T) {
	h := ansi.SetHyperlink("https://example.com")
	if h != "\x1b]8;;https://example.com\x07" {
		t.Errorf("Unexpected hyperlink: %s", h)
	}
}

func TestNewHyperlinkParams(t *testing.T) {
	h := ansi.SetHyperlink("https://example.com", "color=blue", "size=12")
	if h != "\x1b]8;color=blue:size=12;https://example.com\x07" {
		t.Errorf("Unexpected hyperlink: %s", h)
	}
}

func TestHyperlinkReset(t *testing.T) {
	h := ansi.SetHyperlink("")
	if h != "\x1b]8;;\x07" {
		t.Errorf("Unexpected hyperlink: %s", h)
	}
}