Create application sign widget.

This commit is contained in:
Александр Колосов 2024-02-03 01:53:55 +05:00
parent 43e76717e8
commit 5384c9bae2
3 changed files with 28 additions and 0 deletions

View File

@ -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))
}

View File

@ -0,0 +1,5 @@
package widgets
type Widget interface {
Render() string
}

View File

@ -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)
}