summaryrefslogtreecommitdiff
path: root/gemini/gemtext/parse_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'gemini/gemtext/parse_test.go')
-rw-r--r--gemini/gemtext/parse_test.go39
1 files changed, 24 insertions, 15 deletions
diff --git a/gemini/gemtext/parse_test.go b/gemini/gemtext/parse_test.go
index d2860ff..6b35431 100644
--- a/gemini/gemtext/parse_test.go
+++ b/gemini/gemtext/parse_test.go
@@ -24,6 +24,8 @@ This is some non-blank regular text.
=> gemini://google.com/ as if
+=: spartan://foo.bar/baz this should be a spartan prompt
+
> this is a quote
> -tjp
@@ -37,7 +39,7 @@ This is some non-blank regular text.
doc, err := gemtext.Parse(bytes.NewBuffer(docBytes))
require.Nil(t, err)
- require.Equal(t, 18, len(doc))
+ require.Equal(t, 20, len(doc))
assert.Equal(t, gemtext.LineTypeHeading1, doc[0].Type())
assert.Equal(t, "# top-level header line\n", string(doc[0].Raw()))
@@ -74,26 +76,33 @@ This is some non-blank regular text.
assertEmptyLine(t, doc[11])
- assert.Equal(t, gemtext.LineTypeQuote, doc[12].Type())
- assert.Equal(t, "> this is a quote\n", string(doc[12].Raw()))
- assert.Equal(t, " this is a quote", doc[12].(gemtext.QuoteLine).Body())
+ assert.Equal(t, gemtext.LineTypePrompt, doc[12].Type())
+ assert.Equal(t, "=: spartan://foo.bar/baz this should be a spartan prompt\n", string(doc[12].Raw()))
+ assert.Equal(t, "spartan://foo.bar/baz", doc[12].(gemtext.PromptLine).URL())
+ assert.Equal(t, "this should be a spartan prompt", doc[12].(gemtext.PromptLine).Label())
- assert.Equal(t, gemtext.LineTypeQuote, doc[13].Type())
- assert.Equal(t, "> -tjp\n", string(doc[13].Raw()))
- assert.Equal(t, " -tjp", doc[13].(gemtext.QuoteLine).Body())
+ assertEmptyLine(t, doc[13])
- assertEmptyLine(t, doc[14])
+ assert.Equal(t, gemtext.LineTypeQuote, doc[14].Type())
+ assert.Equal(t, "> this is a quote\n", string(doc[14].Raw()))
+ assert.Equal(t, " this is a quote", doc[14].(gemtext.QuoteLine).Body())
- assert.Equal(t, gemtext.LineTypePreformatToggle, doc[15].Type())
- assert.Equal(t, "```pre-formatted code\n", string(doc[15].Raw()))
- assert.Equal(t, "pre-formatted code", doc[15].(gemtext.PreformatToggleLine).AltText())
+ assert.Equal(t, gemtext.LineTypeQuote, doc[15].Type())
+ assert.Equal(t, "> -tjp\n", string(doc[15].Raw()))
+ assert.Equal(t, " -tjp", doc[15].(gemtext.QuoteLine).Body())
- assert.Equal(t, gemtext.LineTypePreformattedText, doc[16].Type())
- assert.Equal(t, "doc := gemtext.Parse(req.Body)\n", string(doc[16].Raw()))
+ assertEmptyLine(t, doc[16])
assert.Equal(t, gemtext.LineTypePreformatToggle, doc[17].Type())
- assert.Equal(t, "```ignored closing alt-text\n", string(doc[17].Raw()))
- assert.Equal(t, "", doc[17].(gemtext.PreformatToggleLine).AltText())
+ assert.Equal(t, "```pre-formatted code\n", string(doc[17].Raw()))
+ assert.Equal(t, "pre-formatted code", doc[17].(gemtext.PreformatToggleLine).AltText())
+
+ assert.Equal(t, gemtext.LineTypePreformattedText, doc[18].Type())
+ assert.Equal(t, "doc := gemtext.Parse(req.Body)\n", string(doc[18].Raw()))
+
+ assert.Equal(t, gemtext.LineTypePreformatToggle, doc[19].Type())
+ assert.Equal(t, "```ignored closing alt-text\n", string(doc[19].Raw()))
+ assert.Equal(t, "", doc[19].(gemtext.PreformatToggleLine).AltText())
// ensure we can rebuild the original doc from all the line.Raw()s
buf := &bytes.Buffer{}