Skip to content

Commit

Permalink
feat: add writetextln function to doc
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Rose <[email protected]>
  • Loading branch information
matty-rose committed Nov 27, 2021
1 parent 1a85a15 commit fd522c3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/document/markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ func (m *MarkdownDocument) WriteNewLine() *MarkdownDocument {
return m
}

func (m *MarkdownDocument) WriteTextLn(text string) *MarkdownDocument {
m.WriteText(text)
m.WriteNewLine()

return m
}

type MarkdownHeadingLevel int

const (
Expand Down
13 changes: 13 additions & 0 deletions pkg/document/markdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ THE SOFTWARE.
package document_test

import (
"fmt"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -56,6 +57,18 @@ func TestMarkdownWriteNewLine(t *testing.T) {
assert.Equal(t, "\n", doc.Render())
}

func TestMarkdownWriteTextLn(t *testing.T) {
t.Parallel()

testStrings := []string{"hello", "these are the", "test strings!"}
for _, s := range testStrings {
doc := document.NewMarkdownDocument()
doc.WriteTextLn(s)

assert.Equal(t, fmt.Sprintf("%s\n", s), doc.Render())
}
}

func TestMarkdownWriteHeading(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit fd522c3

Please sign in to comment.