Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unit tests #24

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]))
})
})
})
Loading