mirror of
https://github.com/navidys/tvxwidgets.git
synced 2025-04-24 13:48:51 +08:00
unit tests
Signed-off-by: Navid Yaghoobi <navidys@fedoraproject.org>
This commit is contained in:
parent
36cc9e3c83
commit
45b787ac4a
@ -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])))
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -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]))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user