Skip to content

Commit d701117

Browse files
committed
update some tests
1 parent bb87a35 commit d701117

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

color_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ func TestRenderCode(t *testing.T) {
168168
str = RenderString("36;1", "Text")
169169
is.Equal("Text", str)
170170
Enable = true
171+
172+
is.Empty(GetErrors())
171173
}
172174

173175
func TestClearCode(t *testing.T) {

tag_test.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,21 @@ func TestParseCodeFromAttr(t *testing.T) {
8181
}
8282

8383
func TestPrint(t *testing.T) {
84+
is := assert.New(t)
85+
86+
s := Sprint()
87+
is.Equal("", s)
88+
8489
// force open color render for testing
8590
buf := forceOpenColorRender()
8691
defer resetColorRender()
87-
is := assert.New(t)
8892

8993
is.True(len(GetColorTags()) > 0)
9094
is.True(IsDefinedTag("info"))
9195
is.Equal("0;32", GetTagCode("info"))
9296
is.Equal("", GetTagCode("not-exist"))
9397

94-
s := Sprint("<red>MSG</>")
98+
s = Sprint("<red>MSG</>")
9599
is.Equal("\x1b[0;31mMSG\x1b[0m", s)
96100

97101
s = Sprint("<red>H</><green>I</>")

utils_test.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ func TestUtilFuncs(t *testing.T) {
2828
is.NoError(os.Unsetenv("MSYSTEM"))
2929
is.False(IsMSys())
3030
_ = os.Setenv("MSYSTEM", oldVal)
31+
}
32+
33+
func TestIsSupportColor(t *testing.T) {
34+
is := assert.New(t)
3135

3236
// IsSupport256Color
33-
oldVal = os.Getenv("TERM")
37+
oldVal := os.Getenv("TERM")
3438
_ = os.Unsetenv("TERM")
3539
is.False(IsSupportColor())
3640
is.False(IsSupport256Color())
@@ -59,13 +63,19 @@ func TestUtilFuncs(t *testing.T) {
5963
// TERM
6064
mockEnvValue("TERM", "tmux-256color", func(_ string) {
6165
is.True(IsSupportColor())
66+
is.Equal("TERM=tmux-256color", SupColorMark())
6267
})
6368

6469
// TERM
6570
mockEnvValue("TERM", "rxvt-unicode-256color", func(_ string) {
6671
is.True(IsSupportColor())
6772
})
6873

74+
// TERM
75+
mockEnvValue("TERM", "alacritty", func(_ string) {
76+
is.True(IsSupportColor())
77+
})
78+
6979
is.NoError(os.Setenv("TERM", "xterm-vt220"))
7080
is.True(IsSupportColor())
7181
// revert

0 commit comments

Comments
 (0)