Skip to content

Commit

Permalink
Added tests for util package
Browse files Browse the repository at this point in the history
  • Loading branch information
achannarasappa committed Jan 9, 2021
1 parent 57b5ea0 commit f072d95
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
13 changes: 13 additions & 0 deletions internal/ui/util/util_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package util_test

import (
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

func TestUtil(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Util Suite")
}
29 changes: 29 additions & 0 deletions internal/ui/util/util_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package util_test

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

. "ticker-tape/internal/ui/util"
)

var _ = Describe("Util", func() {
Describe("ConvertFloatToString", func() {
It("should convert a float to a string with a precision of two", func() {
output := ConvertFloatToString(12.5634)
Expect(output).To(Equal("12.56"))
})
})
Describe("NewStyle", func() {
It("should generate text with a background and foreground color", func() {
inputStyleFn := NewStyle("#ffffff", "#000000", false)
output := inputStyleFn("test")
Expect(output).To(Equal("\x1b[38;5;231;48;5;16mtest\x1b[0m"))
})
It("should generate text with bold styling", func() {
inputStyleFn := NewStyle("#ffffff", "#000000", true)
output := inputStyleFn("test")
Expect(output).To(Equal("\x1b[38;5;231;48;5;16;1mtest\x1b[0m"))
})
})
})

0 comments on commit f072d95

Please sign in to comment.