mirror of
https://github.com/dnwSilver/tld.git
synced 2025-04-28 07:56:18 +00:00
✨ Create application sign widget.
This commit is contained in:
parent
43e76717e8
commit
5384c9bae2
16
internal/pkg/widgets/application_sign.go
Normal file
16
internal/pkg/widgets/application_sign.go
Normal 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))
|
||||
}
|
5
internal/pkg/widgets/widget.go
Normal file
5
internal/pkg/widgets/widget.go
Normal file
@ -0,0 +1,5 @@
|
||||
package widgets
|
||||
|
||||
type Widget interface {
|
||||
Render() string
|
||||
}
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user