unit tests

Signed-off-by: Navid Yaghoobi <navidys@fedoraproject.org>
This commit is contained in:
Navid Yaghoobi 2023-12-20 20:40:02 +11:00
parent 36cc9e3c83
commit 45b787ac4a
2 changed files with 64 additions and 0 deletions

View File

@ -63,4 +63,30 @@ var _ = Describe("Sparkline", Ordered, func() {
Expect(heigth).To(Equal(50))
})
})
Describe("DataTitle and Color", func() {
It("checks data title text and color", func() {
tests := []struct {
title string
color tcell.Color
}{
{title: "test01", color: tcell.ColorDarkOrange},
{title: "abc123", color: tcell.ColorBlue},
}
for _, test := range tests {
sparkline.SetDataTitle(test.title)
sparkline.SetDataTitleColor(test.color)
app.Draw()
for x := 0; x < len(test.title); x++ {
prune, _, style, _ := screen.GetContent(x, 1)
fg, _, _ := style.Decompose()
Expect(fg).To(Equal(test.color))
Expect(string(prune)).To(Equal(string(test.title[x])))
}
}
})
})
})

View File

@ -63,4 +63,42 @@ var _ = Describe("Spinner", Ordered, func() {
Expect(heigth).To(Equal(50))
})
})
Describe("Style", func() {
It("checks style", func() {
spinner.SetStyle(tvxwidgets.SpinnerGrowHorizontal)
spinner.Reset()
app.Draw()
prune, _, _, _ := screen.GetContent(0, 1)
Expect(prune).To(Equal('▉'))
spinner.Pulse()
app.Draw()
prune, _, _, _ = screen.GetContent(0, 1)
Expect(prune).To(Equal('▊'))
})
})
Describe("CustomStyle", func() {
It("checks custom style", func() {
customStyle := []rune{'\u2705', '\u274C'}
spinner.SetCustomStyle(customStyle)
spinner.Reset()
app.Draw()
prune, _, _, _ := screen.GetContent(0, 1)
Expect(prune).To(Equal(customStyle[0]))
spinner.Pulse()
app.Draw()
prune, _, _, _ = screen.GetContent(0, 1)
Expect(prune).To(Equal(customStyle[1]))
spinner.Pulse()
app.Draw()
prune, _, _, _ = screen.GetContent(0, 1)
Expect(prune).To(Equal(customStyle[0]))
})
})
})