Write unit tests
savioxavier opened this issue · 0 comments
savioxavier commented
Description
Unit tests need to be written for this package - using a mixture of the assert
package from stretchr/testify and Go's native testing
library.
The tests need to support both hyperlink supporting and non-hyperlink supporting terminals, by using this package's SupportsHyperlinks()
method. A basic test would look something like this:
func TestBasicLink(t *testing.T) {
if termlink.SupportsHyperlinks() {
assert.Equal(t, termlink.Link("Hello", "https://google.com"), "\x1b]8;;https://google.com\aHello\x1b]8;;\a\x1b[m")
} else {
assert.Equal(t, termlink.Link("Hello", "https://google.com"), "Hello (\u200Bhttps://google.com)\u001b[m")
}
}
go test -v
The tests would need to be run in both terminals - one that supports hyperlinks, and one that doesn't. I'll be using a few AI assisted tools to speed up testing. A few basic tests would do fine as of now, more tests can be added later.
If all the tests work as expected, then it's all good to go!
Assigning this issue to myself. Should be an easy enough job.