package formatting import ( "testing" ) func TestFormatEmail(t *testing.T) { testCases := []struct { inputJSON string expectedURL string }{ { inputJSON: `{ "address": "testing@example.com" }`, expectedURL: "mailto:testing@example.com", }, { inputJSON: `{ "address": "testing@example.com", "subject": "Hello", "cc": "cc@example.com" }`, expectedURL: "mailto:testing@example.com?cc=cc%40example.com&subject=Hello", }, { inputJSON: `{ "address": "testing@example.com", "subject": "Subject", "cc": "cc@example.com", "bcc": "bcc@example.com", "content": "this is email content" }`, expectedURL: "mailto:testing@example.com?bcc=bcc%40example.com&body=this+is+email+content&cc=cc%40example.com&subject=Subject", }, } for _, testCase := range testCases { result, err := formatEMail(testCase.inputJSON) if err != nil { t.Errorf("Unexpected Error: %v", err) } if result != testCase.expectedURL { t.Errorf("Input JSON: \n%s\n\nExpected: %s\n\n Got: %s", testCase.inputJSON, testCase.expectedURL, result) } } }