💾 Archived View for anachronauts.club › cgi-bin › repos › cgi › gmikit.git › tree › trunk › html_tes… captured on 2021-12-05 at 23:47:19. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
1 package gmikit 2 3 import ( 4 "strings" 5 "testing" 6 ) 7 8 func TestConvertEmpty(t *testing.T) { 9 expected := "" 10 input := strings.NewReader(expected) 11 var output strings.Builder 12 if err := GmiToHtml(input, &output); err != nil { 13 t.Error(err) 14 } 15 16 actual := output.String() 17 if expected != actual { 18 t.Errorf("Expected %v got %v", expected, actual) 19 } 20 } 21 22 func TestConvertComplex(t *testing.T) { 23 input := strings.NewReader(`# Heading 1 24 25 Text, more text. 26 27 => hello.gmi Hello! 28 29 > One 30 > Two 31 > Three 32 33 ` + 34 "```a\n" + 35 "tested\n" + 36 "```b\n") 37 38 expected := `<h1>Heading 1</h1> 39 <p> 40 Text, more text. 41 42 </p> 43 <a href="hello.gmi">Hello!</a><br/> 44 <p> 45 </p> 46 <blockquote>One 47 Two 48 Three 49 </blockquote> 50 <p> 51 </p> 52 <div aria-label="a"> 53 <pre aria-hidden="true" alt="a"> 54 tested 55 </pre> 56 </div> 57 ` 58 59 var output strings.Builder 60 if err := GmiToHtml(input, &output); err != nil { 61 t.Error(err) 62 } 63 64 actual := output.String() 65 if expected != actual { 66 t.Errorf("Expected %v got %v", expected, actual) 67 } 68 }