From a7d8ce73b945b658cecaa0337a114b0e4ae01eda Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Tue, 13 Feb 2024 11:17:24 -0800 Subject: [PATCH] initial commits --- writeframebutton4.go | 21 ++++++++++++ writeframebutton4_test.go | 68 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 writeframebutton4.go create mode 100644 writeframebutton4_test.go diff --git a/writeframebutton4.go b/writeframebutton4.go new file mode 100644 index 0000000..46bd2ec --- /dev/null +++ b/writeframebutton4.go @@ -0,0 +1,21 @@ +package frameproto + +import ( + "io" +) + +// WriteFrameButton4 will write the HTML element for the Frame-Protocol's (i.e., Farcaster Frame's) "fc:frame:button:4" name-value pair. +// +// For example, this call: +// +// var label string = "go forward" +// +// frameproto.WriteFrameButton4(writer, label) +// +// Would write this HTML element: +// +// +func WriteFrameButton4(writer io.Writer, label string) { + const property string = MetaPropertyFrameButton4 + writeMetaPropertyContent(writer, property, label) +} diff --git a/writeframebutton4_test.go b/writeframebutton4_test.go new file mode 100644 index 0000000..1b33352 --- /dev/null +++ b/writeframebutton4_test.go @@ -0,0 +1,68 @@ +package frameproto + +import ( + "testing" + + "strings" +) + +func TestWriteFrameButton4(t *testing.T) { + + tests := []struct{ + Label string + Expected string + }{ + { + Label: "", + Expected: ``+"\n", + }, + + + + { + Label: "something", + Expected: ``+"\n", + }, + + + + { + Label: "Hello world! 🙂", + Expected: ``+"\n", + }, + + + + { + Label: "go forward", + Expected: ``+"\n", + }, + + + + { + Label: "I like to eat, eat, eat, apples and bananas", + Expected: ``+"\n", + }, + } + + for testNumber, test := range tests { + + var buffer strings.Builder + + WriteFrameButton4(&buffer, test.Label) + + expected := test.Expected + actual := buffer.String() + + if expected != actual { + t.Errorf("For test #%d, the actual written meta-tag is not what was expected." ,testNumber) + t.Logf("EXPECTED: %s", expected) + t.Logf("ACTUAL: %s", actual) + t.Logf("EXPECTED: %q", expected) + t.Logf("ACTUAL: %q", actual) + t.Logf("LABEL: %q", test.Label) + continue + } + } +}