diff --git a/appendframebutton1.go b/appendframebutton1.go new file mode 100644 index 0000000..6654c0b --- /dev/null +++ b/appendframebutton1.go @@ -0,0 +1,21 @@ +package frameproto + +// AppendFrameButton1 will append the HTML element for the Frame-Protocol's (i.e., Farcaster Frame's) "fc:frame:button:1" name-value pair. +// +// For example, this call: +// +// var p []byte +// +// // ... +// +// var label string = "go forward" +// +// p = frameproto.AppendFrameButton1(p, label) +// +// Would append this HTML element: +// +// +func AppendFrameButton1(p []byte, label string) []byte { + const property string = MetaPropertyFrameButton1 + return appendMetaPropertyContent(p, property, label) +} diff --git a/appendframebutton1_test.go b/appendframebutton1_test.go new file mode 100644 index 0000000..8af58ec --- /dev/null +++ b/appendframebutton1_test.go @@ -0,0 +1,96 @@ +package frameproto + +import ( + "testing" +) + +func TestAppendFrameButton1(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 [256]byte + var p []byte = buffer[0:0] + + p = AppendFrameButton1(p, test.Label) + + expected := test.Expected + actual := string(p) + + 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 + } + } + + { + const top string = "\n\n" + const bottom string = "\n\n\n\n" + + var buffer [256]byte + var p []byte = buffer[0:0] + + p = append(p, top...) + + p = AppendFrameButton1(p, test.Label) + + p = append(p, bottom...) + + expected := top + test.Expected + bottom + actual := string(p) + + 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 + } + } + } +} diff --git a/appendframebutton2.go b/appendframebutton2.go new file mode 100644 index 0000000..d1b2c46 --- /dev/null +++ b/appendframebutton2.go @@ -0,0 +1,21 @@ +package frameproto + +// AppendFrameButton2 will append the HTML element for the Frame-Protocol's (i.e., Farcaster Frame's) "fc:frame:button:2" name-value pair. +// +// For example, this call: +// +// var p []byte +// +// // ... +// +// var label string = "go forward" +// +// p = frameproto.AppendFrameButton2(p, label) +// +// Would append this HTML element: +// +// +func AppendFrameButton2(p []byte, label string) []byte { + const property string = MetaPropertyFrameButton2 + return appendMetaPropertyContent(p, property, label) +} diff --git a/appendframebutton2_test.go b/appendframebutton2_test.go new file mode 100644 index 0000000..e9230ac --- /dev/null +++ b/appendframebutton2_test.go @@ -0,0 +1,96 @@ +package frameproto + +import ( + "testing" +) + +func TestAppendFrameButton2(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 [256]byte + var p []byte = buffer[0:0] + + p = AppendFrameButton2(p, test.Label) + + expected := test.Expected + actual := string(p) + + 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 + } + } + + { + const top string = "\n\n" + const bottom string = "\n\n\n\n" + + var buffer [256]byte + var p []byte = buffer[0:0] + + p = append(p, top...) + + p = AppendFrameButton2(p, test.Label) + + p = append(p, bottom...) + + expected := top + test.Expected + bottom + actual := string(p) + + 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 + } + } + } +} diff --git a/appendframebutton3.go b/appendframebutton3.go new file mode 100644 index 0000000..c86cf0d --- /dev/null +++ b/appendframebutton3.go @@ -0,0 +1,21 @@ +package frameproto + +// AppendFrameButton3 will append the HTML element for the Frame-Protocol's (i.e., Farcaster Frame's) "fc:frame:button:3" name-value pair. +// +// For example, this call: +// +// var p []byte +// +// // ... +// +// var label string = "go forward" +// +// p = frameproto.AppendFrameButton3(p, label) +// +// Would append this HTML element: +// +// +func AppendFrameButton3(p []byte, label string) []byte { + const property string = MetaPropertyFrameButton3 + return appendMetaPropertyContent(p, property, label) +} diff --git a/appendframebutton3_test.go b/appendframebutton3_test.go new file mode 100644 index 0000000..84bb258 --- /dev/null +++ b/appendframebutton3_test.go @@ -0,0 +1,96 @@ +package frameproto + +import ( + "testing" +) + +func TestAppendFrameButton3(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 [256]byte + var p []byte = buffer[0:0] + + p = AppendFrameButton3(p, test.Label) + + expected := test.Expected + actual := string(p) + + 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 + } + } + + { + const top string = "\n\n" + const bottom string = "\n\n\n\n" + + var buffer [256]byte + var p []byte = buffer[0:0] + + p = append(p, top...) + + p = AppendFrameButton3(p, test.Label) + + p = append(p, bottom...) + + expected := top + test.Expected + bottom + actual := string(p) + + 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 + } + } + } +} diff --git a/appendframebutton4.go b/appendframebutton4.go new file mode 100644 index 0000000..be0c70a --- /dev/null +++ b/appendframebutton4.go @@ -0,0 +1,21 @@ +package frameproto + +// AppendFrameButton4 will append 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 p []byte +// +// // ... +// +// var label string = "go forward" +// +// p = frameproto.AppendFrameButton4(p, label) +// +// Would append this HTML element: +// +// +func AppendFrameButton4(p []byte, label string) []byte { + const property string = MetaPropertyFrameButton4 + return appendMetaPropertyContent(p, property, label) +} diff --git a/appendframebutton4_test.go b/appendframebutton4_test.go new file mode 100644 index 0000000..785b26c --- /dev/null +++ b/appendframebutton4_test.go @@ -0,0 +1,96 @@ +package frameproto + +import ( + "testing" +) + +func TestAppendFrameButton4(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 [256]byte + var p []byte = buffer[0:0] + + p = AppendFrameButton4(p, test.Label) + + expected := test.Expected + actual := string(p) + + 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 + } + } + + { + const top string = "\n\n" + const bottom string = "\n\n\n\n" + + var buffer [256]byte + var p []byte = buffer[0:0] + + p = append(p, top...) + + p = AppendFrameButton4(p, test.Label) + + p = append(p, bottom...) + + expected := top + test.Expected + bottom + actual := string(p) + + 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 + } + } + } +}