diff --git a/stringframe.go b/stringframe.go new file mode 100644 index 0000000..3f5da10 --- /dev/null +++ b/stringframe.go @@ -0,0 +1,24 @@ +package frameproto + +// StringFrame will return the HTML element for the Frame-Protocol's (i.e., Farcaster Frame's) "fc:frame" name-value pair. +// +// For example, this call: +// +// var version string = "vNext" +// +// s = frameproto.StringFrame(version) +// +// Would return this HTML element: +// +// +// +// Note that this package provides some constants to use with StringFrame. +// Namely: VersionVNext (for "vNext"). +// +// Which in code would be used as: +// +// p = frameproto.StringFrame(p, frameproto.VersionVNext) +func StringFrame(version string) string { + const property string = MetaPropertyFrame + return stringMetaPropertyContent(property, version) +} diff --git a/stringframe_test.go b/stringframe_test.go new file mode 100644 index 0000000..c414bbf --- /dev/null +++ b/stringframe_test.go @@ -0,0 +1,63 @@ +package frameproto + +import ( + "testing" +) + +func TestStringFrame(t *testing.T) { + + tests := []struct{ + Version string + Expected string + }{ + { + Version: "", + Expected: ``+"\n", + }, + + + + { + Version: "something", + Expected: ``+"\n", + }, + + + + { + Version: "Hello world! 🙂", + Expected: ``+"\n", + }, + + + + { + Version: "vNext", + Expected: ``+"\n", + }, + + + + { + Version: "2020-01-01", + Expected: ``+"\n", + }, + } + + for testNumber, test := range tests { + + actual := StringFrame(test.Version) + + 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.Version) + continue + } + } +}