diff --git a/stringframebutton1action.go b/stringframebutton1action.go new file mode 100644 index 0000000..7acd3ad --- /dev/null +++ b/stringframebutton1action.go @@ -0,0 +1,36 @@ +package frameproto + +// StringFrameButton1Action will return the HTML element for the Frame-Protocol's (i.e., Farcaster Frame's) "fc:frame:button:1:action" name-value pair. +// +// For example, this call: +// +// var buttonAction string = "post" +// +// str := frameproto.StringFrameButton1Action(aspectRatio) +// +// Would return this HTML element: +// +// +// +// Note that this package provides some constants to use with StringFrameButton1Action. +// Namely: ButtonActionLink (for "link"), ButtonActionMint (for "mint"), ButtonActionPost (for "post"), and ButtonActionPostRedirect (for "post_redirect"). +// +// Which in code would be used as: +// +// str := frameproto.StringFrameButton1Action(frameproto.ButtonActionLink) +// +// And: +// +// str := frameproto.StringFrameButton1Action(frameproto.ButtonActionMint) +// +// And: +// +// str :+ frameproto.StringFrameButton1Action(frameproto.ButtonActionPost) +// +// And: +// +// str := frameproto.StringFrameButton1Action(frameproto.ButtonActionPostRedirect) +func StringFrameButton1Action(action string) string { + const property string = MetaPropertyFrameButton1Action + return stringMetaPropertyContent(property, action) +} diff --git a/stringframebutton1action_test.go b/stringframebutton1action_test.go new file mode 100644 index 0000000..6585d96 --- /dev/null +++ b/stringframebutton1action_test.go @@ -0,0 +1,68 @@ +package frameproto + +import ( + "testing" +) + +func TestStringFrameButton1Action(t *testing.T) { + + tests := []struct{ + Label string + Expected string + }{ + { + Label: "", + Expected: ``+"\n", + }, + + + + { + Label: "something", + Expected: ``+"\n", + }, + + + + { + Label: "Hello world! 🙂", + Expected: ``+"\n", + }, + + + + { + Label: "link", + Expected: ``+"\n", + }, + { + Label: "mint", + Expected: ``+"\n", + }, + { + Label: "post", + Expected: ``+"\n", + }, + { + Label: "post_redirect", + Expected: ``+"\n", + }, + } + + for testNumber, test := range tests { + + actual := StringFrameButton1Action(test.Label) + + expected := test.Expected + + 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/stringframebutton2action.go b/stringframebutton2action.go new file mode 100644 index 0000000..2f59c74 --- /dev/null +++ b/stringframebutton2action.go @@ -0,0 +1,36 @@ +package frameproto + +// StringFrameButton2Action will return the HTML element for the Frame-Protocol's (i.e., Farcaster Frame's) "fc:frame:button:2:action" name-value pair. +// +// For example, this call: +// +// var buttonAction string = "post" +// +// str := frameproto.StringFrameButton2Action(aspectRatio) +// +// Would return this HTML element: +// +// +// +// Note that this package provides some constants to use with StringFrameButton2Action. +// Namely: ButtonActionLink (for "link"), ButtonActionMint (for "mint"), ButtonActionPost (for "post"), and ButtonActionPostRedirect (for "post_redirect"). +// +// Which in code would be used as: +// +// str := frameproto.StringFrameButton2Action(frameproto.ButtonActionLink) +// +// And: +// +// str := frameproto.StringFrameButton2Action(frameproto.ButtonActionMint) +// +// And: +// +// str :+ frameproto.StringFrameButton2Action(frameproto.ButtonActionPost) +// +// And: +// +// str := frameproto.StringFrameButton2Action(frameproto.ButtonActionPostRedirect) +func StringFrameButton2Action(action string) string { + const property string = MetaPropertyFrameButton2Action + return stringMetaPropertyContent(property, action) +} diff --git a/stringframebutton2action_test.go b/stringframebutton2action_test.go new file mode 100644 index 0000000..fe88d85 --- /dev/null +++ b/stringframebutton2action_test.go @@ -0,0 +1,68 @@ +package frameproto + +import ( + "testing" +) + +func TestStringFrameButton2Action(t *testing.T) { + + tests := []struct{ + Label string + Expected string + }{ + { + Label: "", + Expected: ``+"\n", + }, + + + + { + Label: "something", + Expected: ``+"\n", + }, + + + + { + Label: "Hello world! 🙂", + Expected: ``+"\n", + }, + + + + { + Label: "link", + Expected: ``+"\n", + }, + { + Label: "mint", + Expected: ``+"\n", + }, + { + Label: "post", + Expected: ``+"\n", + }, + { + Label: "post_redirect", + Expected: ``+"\n", + }, + } + + for testNumber, test := range tests { + + actual := StringFrameButton2Action(test.Label) + + expected := test.Expected + + 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/stringframebutton3action.go b/stringframebutton3action.go new file mode 100644 index 0000000..655cd56 --- /dev/null +++ b/stringframebutton3action.go @@ -0,0 +1,36 @@ +package frameproto + +// StringFrameButton3Action will return the HTML element for the Frame-Protocol's (i.e., Farcaster Frame's) "fc:frame:button:3:action" name-value pair. +// +// For example, this call: +// +// var buttonAction string = "post" +// +// str := frameproto.StringFrameButton3Action(aspectRatio) +// +// Would return this HTML element: +// +// +// +// Note that this package provides some constants to use with StringFrameButton3Action. +// Namely: ButtonActionLink (for "link"), ButtonActionMint (for "mint"), ButtonActionPost (for "post"), and ButtonActionPostRedirect (for "post_redirect"). +// +// Which in code would be used as: +// +// str := frameproto.StringFrameButton3Action(frameproto.ButtonActionLink) +// +// And: +// +// str := frameproto.StringFrameButton3Action(frameproto.ButtonActionMint) +// +// And: +// +// str :+ frameproto.StringFrameButton3Action(frameproto.ButtonActionPost) +// +// And: +// +// str := frameproto.StringFrameButton3Action(frameproto.ButtonActionPostRedirect) +func StringFrameButton3Action(action string) string { + const property string = MetaPropertyFrameButton3Action + return stringMetaPropertyContent(property, action) +} diff --git a/stringframebutton3action_test.go b/stringframebutton3action_test.go new file mode 100644 index 0000000..c9c8653 --- /dev/null +++ b/stringframebutton3action_test.go @@ -0,0 +1,68 @@ +package frameproto + +import ( + "testing" +) + +func TestStringFrameButton3Action(t *testing.T) { + + tests := []struct{ + Label string + Expected string + }{ + { + Label: "", + Expected: ``+"\n", + }, + + + + { + Label: "something", + Expected: ``+"\n", + }, + + + + { + Label: "Hello world! 🙂", + Expected: ``+"\n", + }, + + + + { + Label: "link", + Expected: ``+"\n", + }, + { + Label: "mint", + Expected: ``+"\n", + }, + { + Label: "post", + Expected: ``+"\n", + }, + { + Label: "post_redirect", + Expected: ``+"\n", + }, + } + + for testNumber, test := range tests { + + actual := StringFrameButton3Action(test.Label) + + expected := test.Expected + + 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/stringframebutton4action.go b/stringframebutton4action.go new file mode 100644 index 0000000..0d8ad1a --- /dev/null +++ b/stringframebutton4action.go @@ -0,0 +1,36 @@ +package frameproto + +// StringFrameButton4Action will return the HTML element for the Frame-Protocol's (i.e., Farcaster Frame's) "fc:frame:button:4:action" name-value pair. +// +// For example, this call: +// +// var buttonAction string = "post" +// +// str := frameproto.StringFrameButton4Action(aspectRatio) +// +// Would return this HTML element: +// +// +// +// Note that this package provides some constants to use with StringFrameButton4Action. +// Namely: ButtonActionLink (for "link"), ButtonActionMint (for "mint"), ButtonActionPost (for "post"), and ButtonActionPostRedirect (for "post_redirect"). +// +// Which in code would be used as: +// +// str := frameproto.StringFrameButton4Action(frameproto.ButtonActionLink) +// +// And: +// +// str := frameproto.StringFrameButton4Action(frameproto.ButtonActionMint) +// +// And: +// +// str :+ frameproto.StringFrameButton4Action(frameproto.ButtonActionPost) +// +// And: +// +// str := frameproto.StringFrameButton4Action(frameproto.ButtonActionPostRedirect) +func StringFrameButton4Action(action string) string { + const property string = MetaPropertyFrameButton4Action + return stringMetaPropertyContent(property, action) +} diff --git a/stringframebutton4action_test.go b/stringframebutton4action_test.go new file mode 100644 index 0000000..93e016b --- /dev/null +++ b/stringframebutton4action_test.go @@ -0,0 +1,68 @@ +package frameproto + +import ( + "testing" +) + +func TestStringFrameButton4Action(t *testing.T) { + + tests := []struct{ + Label string + Expected string + }{ + { + Label: "", + Expected: ``+"\n", + }, + + + + { + Label: "something", + Expected: ``+"\n", + }, + + + + { + Label: "Hello world! 🙂", + Expected: ``+"\n", + }, + + + + { + Label: "link", + Expected: ``+"\n", + }, + { + Label: "mint", + Expected: ``+"\n", + }, + { + Label: "post", + Expected: ``+"\n", + }, + { + Label: "post_redirect", + Expected: ``+"\n", + }, + } + + for testNumber, test := range tests { + + actual := StringFrameButton4Action(test.Label) + + expected := test.Expected + + 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 + } + } +}