initial commits
parent
23914af3d2
commit
0e905c15c9
|
@ -0,0 +1,36 @@
|
|||
package frameproto
|
||||
|
||||
// StringFrameButton1Action will return the HTML <meta/> 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 <meta/> element:
|
||||
//
|
||||
// <meta property="fc:frame:button:1:action" content="post" />
|
||||
//
|
||||
// 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)
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package frameproto
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestStringFrameButton1Action(t *testing.T) {
|
||||
|
||||
tests := []struct{
|
||||
Label string
|
||||
Expected string
|
||||
}{
|
||||
{
|
||||
Label: "",
|
||||
Expected: `<meta property="fc:frame:button:1:action" content="" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Label: "something",
|
||||
Expected: `<meta property="fc:frame:button:1:action" content="something" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Label: "Hello world! 🙂",
|
||||
Expected: `<meta property="fc:frame:button:1:action" content="Hello world! 🙂" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Label: "link",
|
||||
Expected: `<meta property="fc:frame:button:1:action" content="link" />`+"\n",
|
||||
},
|
||||
{
|
||||
Label: "mint",
|
||||
Expected: `<meta property="fc:frame:button:1:action" content="mint" />`+"\n",
|
||||
},
|
||||
{
|
||||
Label: "post",
|
||||
Expected: `<meta property="fc:frame:button:1:action" content="post" />`+"\n",
|
||||
},
|
||||
{
|
||||
Label: "post_redirect",
|
||||
Expected: `<meta property="fc:frame:button:1:action" content="post_redirect" />`+"\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
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package frameproto
|
||||
|
||||
// StringFrameButton2Action will return the HTML <meta/> 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 <meta/> element:
|
||||
//
|
||||
// <meta property="fc:frame:button:2:action" content="post" />
|
||||
//
|
||||
// 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)
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package frameproto
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestStringFrameButton2Action(t *testing.T) {
|
||||
|
||||
tests := []struct{
|
||||
Label string
|
||||
Expected string
|
||||
}{
|
||||
{
|
||||
Label: "",
|
||||
Expected: `<meta property="fc:frame:button:2:action" content="" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Label: "something",
|
||||
Expected: `<meta property="fc:frame:button:2:action" content="something" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Label: "Hello world! 🙂",
|
||||
Expected: `<meta property="fc:frame:button:2:action" content="Hello world! 🙂" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Label: "link",
|
||||
Expected: `<meta property="fc:frame:button:2:action" content="link" />`+"\n",
|
||||
},
|
||||
{
|
||||
Label: "mint",
|
||||
Expected: `<meta property="fc:frame:button:2:action" content="mint" />`+"\n",
|
||||
},
|
||||
{
|
||||
Label: "post",
|
||||
Expected: `<meta property="fc:frame:button:2:action" content="post" />`+"\n",
|
||||
},
|
||||
{
|
||||
Label: "post_redirect",
|
||||
Expected: `<meta property="fc:frame:button:2:action" content="post_redirect" />`+"\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
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package frameproto
|
||||
|
||||
// StringFrameButton3Action will return the HTML <meta/> 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 <meta/> element:
|
||||
//
|
||||
// <meta property="fc:frame:button:3:action" content="post" />
|
||||
//
|
||||
// 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)
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package frameproto
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestStringFrameButton3Action(t *testing.T) {
|
||||
|
||||
tests := []struct{
|
||||
Label string
|
||||
Expected string
|
||||
}{
|
||||
{
|
||||
Label: "",
|
||||
Expected: `<meta property="fc:frame:button:3:action" content="" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Label: "something",
|
||||
Expected: `<meta property="fc:frame:button:3:action" content="something" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Label: "Hello world! 🙂",
|
||||
Expected: `<meta property="fc:frame:button:3:action" content="Hello world! 🙂" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Label: "link",
|
||||
Expected: `<meta property="fc:frame:button:3:action" content="link" />`+"\n",
|
||||
},
|
||||
{
|
||||
Label: "mint",
|
||||
Expected: `<meta property="fc:frame:button:3:action" content="mint" />`+"\n",
|
||||
},
|
||||
{
|
||||
Label: "post",
|
||||
Expected: `<meta property="fc:frame:button:3:action" content="post" />`+"\n",
|
||||
},
|
||||
{
|
||||
Label: "post_redirect",
|
||||
Expected: `<meta property="fc:frame:button:3:action" content="post_redirect" />`+"\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
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package frameproto
|
||||
|
||||
// StringFrameButton4Action will return the HTML <meta/> 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 <meta/> element:
|
||||
//
|
||||
// <meta property="fc:frame:button:4:action" content="post" />
|
||||
//
|
||||
// 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)
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package frameproto
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestStringFrameButton4Action(t *testing.T) {
|
||||
|
||||
tests := []struct{
|
||||
Label string
|
||||
Expected string
|
||||
}{
|
||||
{
|
||||
Label: "",
|
||||
Expected: `<meta property="fc:frame:button:4:action" content="" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Label: "something",
|
||||
Expected: `<meta property="fc:frame:button:4:action" content="something" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Label: "Hello world! 🙂",
|
||||
Expected: `<meta property="fc:frame:button:4:action" content="Hello world! 🙂" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Label: "link",
|
||||
Expected: `<meta property="fc:frame:button:4:action" content="link" />`+"\n",
|
||||
},
|
||||
{
|
||||
Label: "mint",
|
||||
Expected: `<meta property="fc:frame:button:4:action" content="mint" />`+"\n",
|
||||
},
|
||||
{
|
||||
Label: "post",
|
||||
Expected: `<meta property="fc:frame:button:4:action" content="post" />`+"\n",
|
||||
},
|
||||
{
|
||||
Label: "post_redirect",
|
||||
Expected: `<meta property="fc:frame:button:4:action" content="post_redirect" />`+"\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
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue