diff --git a/internal/pkg/widgets/application_sign.go b/internal/pkg/widgets/application_sign.go new file mode 100644 index 0000000..95f793a --- /dev/null +++ b/internal/pkg/widgets/application_sign.go @@ -0,0 +1,16 @@ +package widgets + +import "strconv" + +type ApplicationSignWidget struct { + name string + year int16 +} + +func ApplicationSign(name string, year int16) Widget { + return ApplicationSignWidget{name, year} +} + +func (widget ApplicationSignWidget) Render() string { + return `󰗦 ` + widget.name + ", " + strconv.Itoa(int(widget.year)) +} diff --git a/internal/pkg/widgets/widget.go b/internal/pkg/widgets/widget.go new file mode 100644 index 0000000..5f80a7a --- /dev/null +++ b/internal/pkg/widgets/widget.go @@ -0,0 +1,5 @@ +package widgets + +type Widget interface { + Render() string +} diff --git a/test/example_test.go b/test/example_test.go index 5c11a5d..fb24673 100644 --- a/test/example_test.go +++ b/test/example_test.go @@ -1,6 +1,7 @@ package test import ( + "github.com/dnwsilver/tld/internal/pkg/widgets" "testing" "github.com/stretchr/testify/assert" @@ -33,3 +34,9 @@ func (suite *ExampleTestSuite) TestExample() { func TestExampleTestSuite(t *testing.T) { suite.Run(t, new(ExampleTestSuite)) } + +func TestApplicationSign(t *testing.T) { + widget := widgets.ApplicationSign("John Travolta", 1994) + result := widget.Render() + assert.Equal(t, `󰗦 John Travolta, 1994`, result) +}