Skip to content

Commit

Permalink
Merge pull request #24 from navidys/develop
Browse files Browse the repository at this point in the history
unit tests
  • Loading branch information
navidys authored Dec 20, 2023
2 parents 36cc9e3 + 45b787a commit 82465e0
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
26 changes: 26 additions & 0 deletions sparkline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])))
}
}
})
})
})
38 changes: 38 additions & 0 deletions spinner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
})
})
})

0 comments on commit 82465e0

Please sign in to comment.