From 5384c9bae20295789b3bf971761d32341297b9ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?= =?UTF-8?q?=D0=9A=D0=BE=D0=BB=D0=BE=D1=81=D0=BE=D0=B2?= Date: Sat, 3 Feb 2024 01:53:55 +0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Create=20application=20sign=20widge?= =?UTF-8?q?t.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/pkg/widgets/application_sign.go | 16 ++++++++++++++++ internal/pkg/widgets/widget.go | 5 +++++ test/example_test.go | 7 +++++++ 3 files changed, 28 insertions(+) create mode 100644 internal/pkg/widgets/application_sign.go create mode 100644 internal/pkg/widgets/widget.go 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) +}