Skip to content

Commit

Permalink
Add another hyperlink test
Browse files Browse the repository at this point in the history
Seemed there were no tests for hyperlink rendering.

Now we at least have two.
  • Loading branch information
walles committed Dec 13, 2023
1 parent 14c2351 commit eb48418
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions twin/screen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,28 @@ func TestRenderHyperlinkAtEndOfLine(t *testing.T) {
strings.ReplaceAll(rendered, "", "ESC"),
`ESC[mESC]8;;`+url+`ESC\*ESC]8;;ESC\ESC[K`)
}

func TestMultiCharHyperlink(t *testing.T) {
url := "https://example.com/"
row := []Cell{
{
Rune: '-',
Style: StyleDefault.WithHyperlink(&url),
},
{
Rune: 'X',
Style: StyleDefault.WithHyperlink(&url),
},
{
Rune: '-',
Style: StyleDefault.WithHyperlink(&url),
},
}

rendered, count := renderLine(row)
assert.Equal(t, count, 3)

assert.Equal(t,
strings.ReplaceAll(rendered, "", "ESC"),
`ESC[mESC]8;;`+url+`ESC\-X-ESC]8;;ESC\ESC[K`)
}

0 comments on commit eb48418

Please sign in to comment.