diff --git a/writeframebutton1target.go b/writeframebutton1target.go new file mode 100644 index 0000000..c131408 --- /dev/null +++ b/writeframebutton1target.go @@ -0,0 +1,21 @@ +package frameproto + +import ( + "io" +) + +// WriteFrameButton1Target will write the HTML element for the Frame-Protocol's (i.e., Farcaster Frame's) "fc:frame:button:1:target" name-value pair. +// +// For example, this call: +// +// var target string = "https://example.com/thing/do-it" +// +// frameproto.WriteFrameButton1Target(writer, target) +// +// Would write this HTML element: +// +// +func WriteFrameButton1Target(writer io.Writer, url string) { + const property string = MetaPropertyFrameButton1Target + writeMetaPropertyContent(writer, property, url) +} diff --git a/writeframebutton1target_test.go b/writeframebutton1target_test.go new file mode 100644 index 0000000..ca8fdf7 --- /dev/null +++ b/writeframebutton1target_test.go @@ -0,0 +1,68 @@ +package frameproto + +import ( + "testing" + + "strings" +) + +func TestWriteFrameButton1Target(t *testing.T) { + + tests := []struct{ + Target string + Expected string + }{ + { + Target: "", + Expected: ``+"\n", + }, + + + + { + Target: "something", + Expected: ``+"\n", + }, + + + + { + Target: "Hello world! 🙂", + Expected: ``+"\n", + }, + + + + { + Target: "https://example.com/path/to/post/to.php", + Expected: ``+"\n", + }, + + + + { + Target: "x-proto:apple/banana/cherry", + Expected: ``+"\n", + }, + } + + for testNumber, test := range tests { + + var buffer strings.Builder + + WriteFrameButton1Target(&buffer, test.Target) + + expected := test.Expected + actual := buffer.String() + + 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("Target: %q", test.Target) + continue + } + } +} diff --git a/writeframebutton2target.go b/writeframebutton2target.go new file mode 100644 index 0000000..4aeb6eb --- /dev/null +++ b/writeframebutton2target.go @@ -0,0 +1,21 @@ +package frameproto + +import ( + "io" +) + +// WriteFrameButton2Target will write the HTML element for the Frame-Protocol's (i.e., Farcaster Frame's) "fc:frame:button:2:target" name-value pair. +// +// For example, this call: +// +// var target string = "https://example.com/thing/do-it" +// +// frameproto.WriteFrameButton2Target(writer, target) +// +// Would write this HTML element: +// +// +func WriteFrameButton2Target(writer io.Writer, url string) { + const property string = MetaPropertyFrameButton2Target + writeMetaPropertyContent(writer, property, url) +} diff --git a/writeframebutton2target_test.go b/writeframebutton2target_test.go new file mode 100644 index 0000000..3b7395d --- /dev/null +++ b/writeframebutton2target_test.go @@ -0,0 +1,68 @@ +package frameproto + +import ( + "testing" + + "strings" +) + +func TestWriteFrameButton2Target(t *testing.T) { + + tests := []struct{ + Target string + Expected string + }{ + { + Target: "", + Expected: ``+"\n", + }, + + + + { + Target: "something", + Expected: ``+"\n", + }, + + + + { + Target: "Hello world! 🙂", + Expected: ``+"\n", + }, + + + + { + Target: "https://example.com/path/to/post/to.php", + Expected: ``+"\n", + }, + + + + { + Target: "x-proto:apple/banana/cherry", + Expected: ``+"\n", + }, + } + + for testNumber, test := range tests { + + var buffer strings.Builder + + WriteFrameButton2Target(&buffer, test.Target) + + expected := test.Expected + actual := buffer.String() + + 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("Target: %q", test.Target) + continue + } + } +} diff --git a/writeframebutton3target.go b/writeframebutton3target.go new file mode 100644 index 0000000..303c119 --- /dev/null +++ b/writeframebutton3target.go @@ -0,0 +1,21 @@ +package frameproto + +import ( + "io" +) + +// WriteFrameButton3Target will write the HTML element for the Frame-Protocol's (i.e., Farcaster Frame's) "fc:frame:button:3:target" name-value pair. +// +// For example, this call: +// +// var target string = "https://example.com/thing/do-it" +// +// frameproto.WriteFrameButton3Target(writer, target) +// +// Would write this HTML element: +// +// +func WriteFrameButton3Target(writer io.Writer, url string) { + const property string = MetaPropertyFrameButton3Target + writeMetaPropertyContent(writer, property, url) +} diff --git a/writeframebutton3target_test.go b/writeframebutton3target_test.go new file mode 100644 index 0000000..33a152f --- /dev/null +++ b/writeframebutton3target_test.go @@ -0,0 +1,68 @@ +package frameproto + +import ( + "testing" + + "strings" +) + +func TestWriteFrameButton3Target(t *testing.T) { + + tests := []struct{ + Target string + Expected string + }{ + { + Target: "", + Expected: ``+"\n", + }, + + + + { + Target: "something", + Expected: ``+"\n", + }, + + + + { + Target: "Hello world! 🙂", + Expected: ``+"\n", + }, + + + + { + Target: "https://example.com/path/to/post/to.php", + Expected: ``+"\n", + }, + + + + { + Target: "x-proto:apple/banana/cherry", + Expected: ``+"\n", + }, + } + + for testNumber, test := range tests { + + var buffer strings.Builder + + WriteFrameButton3Target(&buffer, test.Target) + + expected := test.Expected + actual := buffer.String() + + 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("Target: %q", test.Target) + continue + } + } +} diff --git a/writeframebutton4target.go b/writeframebutton4target.go new file mode 100644 index 0000000..6f147ab --- /dev/null +++ b/writeframebutton4target.go @@ -0,0 +1,21 @@ +package frameproto + +import ( + "io" +) + +// WriteFrameButton4Target will write the HTML element for the Frame-Protocol's (i.e., Farcaster Frame's) "fc:frame:button:4:target" name-value pair. +// +// For example, this call: +// +// var target string = "https://example.com/thing/do-it" +// +// frameproto.WriteFrameButton4Target(writer, target) +// +// Would write this HTML element: +// +// +func WriteFrameButton4Target(writer io.Writer, url string) { + const property string = MetaPropertyFrameButton4Target + writeMetaPropertyContent(writer, property, url) +} diff --git a/writeframebutton4target_test.go b/writeframebutton4target_test.go new file mode 100644 index 0000000..1159169 --- /dev/null +++ b/writeframebutton4target_test.go @@ -0,0 +1,68 @@ +package frameproto + +import ( + "testing" + + "strings" +) + +func TestWriteFrameButton4Target(t *testing.T) { + + tests := []struct{ + Target string + Expected string + }{ + { + Target: "", + Expected: ``+"\n", + }, + + + + { + Target: "something", + Expected: ``+"\n", + }, + + + + { + Target: "Hello world! 🙂", + Expected: ``+"\n", + }, + + + + { + Target: "https://example.com/path/to/post/to.php", + Expected: ``+"\n", + }, + + + + { + Target: "x-proto:apple/banana/cherry", + Expected: ``+"\n", + }, + } + + for testNumber, test := range tests { + + var buffer strings.Builder + + WriteFrameButton4Target(&buffer, test.Target) + + expected := test.Expected + actual := buffer.String() + + 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("Target: %q", test.Target) + continue + } + } +}