diff --git a/pkg/parser/document_test.go b/pkg/parser/document_test.go index b5620e76..d3cdd78d 100644 --- a/pkg/parser/document_test.go +++ b/pkg/parser/document_test.go @@ -12,16 +12,103 @@ var _ = Describe("documents", func() { Context("draft document", func() { - It("empty document", func() { + It("should parse empty document", func() { source := `` expected := types.DraftDocument{} Expect(ParseDraftDocument(source)).To(MatchDraftDocument(expected)) }) + + It("should parse header without empty first line", func() { + source := `= My title +Garrett D'Amore +1.0, July 4, 2020 +` + expected := types.DraftDocument{ + Attributes: types.Attributes{ + "revnumber": "1.0", + "revdate": "July 4, 2020", + "author": "Garrett D'Amore", + "authorinitials": "GD", + "authors": []types.DocumentAuthor{ + { + FullName: "Garrett D'Amore", + Email: "", + }, + }, + "firstname": "Garrett", + "lastname": "D'Amore", + "revision": types.DocumentRevision{ + Revnumber: "1.0", + Revdate: "July 4, 2020", + Revremark: "", + }, + }, + Blocks: []interface{}{ + types.Section{ + Level: 0, + Attributes: types.Attributes{ + "id": "_my_title", + }, + Title: []interface{}{ + types.StringElement{ + Content: "My title", + }, + }, + Elements: []interface{}{}, + }, + }, + } + Expect(ParseDraftDocument(source)).To(MatchDraftDocument(expected)) + + }) + + It("should parse header with empty first line", func() { + source := `= My title +Garrett D'Amore +1.0, July 4, 2020` + expected := types.DraftDocument{ + Attributes: types.Attributes{ + "revnumber": "1.0", + "revdate": "July 4, 2020", + "author": "Garrett D'Amore", + "authorinitials": "GD", + "authors": []types.DocumentAuthor{ + { + FullName: "Garrett D'Amore", + Email: "", + }, + }, + "firstname": "Garrett", + "lastname": "D'Amore", + "revision": types.DocumentRevision{ + Revnumber: "1.0", + Revdate: "July 4, 2020", + Revremark: "", + }, + }, + Blocks: []interface{}{ + types.Section{ + Level: 0, + Attributes: types.Attributes{ + "id": "_my_title", + }, + Title: []interface{}{ + types.StringElement{ + Content: "My title", + }, + }, + Elements: []interface{}{}, + }, + }, + } + Expect(ParseDraftDocument(source)).To(MatchDraftDocument(expected)) + + }) }) Context("final document", func() { - It("empty document", func() { + It("should parse empty document", func() { source := `` expected := types.Document{ Elements: []interface{}{},