diff --git a/stringframeimageaspectratio.go b/stringframeimageaspectratio.go new file mode 100644 index 0000000..616c925 --- /dev/null +++ b/stringframeimageaspectratio.go @@ -0,0 +1,28 @@ +package frameproto + +// StringFrameImageAspectRatio will return the HTML element for the Frame-Protocol's (i.e., Farcaster Frame's) "fc:frame:image:aspect_ratio" name-value pair. +// +// For example, this call: +// +// var aspectRatio string = "1.91:1" +// +// str := frameproto.StringFrameImageAspectRatio(aspectRatio) +// +// Would return this HTML element: +// +// +// +// Note that this package provides some constants to use with StringFrameImageAspectRatio. +// Namely: AspectRatioOnePointNineOneToOne (for "1.91:1") and AspectRatioOneToOne (for "1:1"). +// +// Which in code would be used at: +// +// str := frameproto.StringFrameImageAspectRatio(frameproto.AspectRatioOnePointNineOneToOne) +// +// And: +// +// str := frameproto.StringFrameImageAspectRatio(frameproto.AspectRatioOneToOne) +func StringFrameImageAspectRatio(label string) string { + const property string = MetaPropertyFrameImageAspectRatio + return stringMetaPropertyContent(property, label) +} diff --git a/stringframeimageaspectratio_test.go b/stringframeimageaspectratio_test.go new file mode 100644 index 0000000..037aaee --- /dev/null +++ b/stringframeimageaspectratio_test.go @@ -0,0 +1,63 @@ +package frameproto + +import ( + "testing" +) + +func TestStringFrameImageAspectRatio(t *testing.T) { + + tests := []struct{ + AspectRatio string + Expected string + }{ + { + AspectRatio: "", + Expected: ``+"\n", + }, + + + + { + AspectRatio: "something", + Expected: ``+"\n", + }, + + + + { + AspectRatio: "Hello world! 🙂", + Expected: ``+"\n", + }, + + + + { + AspectRatio: "1.91:1", + Expected: ``+"\n", + }, + + + + { + AspectRatio: "1:1", + Expected: ``+"\n", + }, + } + + for testNumber, test := range tests { + + actual := StringFrameImageAspectRatio(test.AspectRatio) + + 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("AspectRatio: %q", test.AspectRatio) + continue + } + } +}