diff options
Diffstat (limited to 'internal/text/plain_test.go')
-rw-r--r-- | internal/text/plain_test.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/internal/text/plain_test.go b/internal/text/plain_test.go index 183ccc478..2f9eb3a29 100644 --- a/internal/text/plain_test.go +++ b/internal/text/plain_test.go @@ -19,6 +19,7 @@ package text_test import ( + "fmt" "testing" "github.com/stretchr/testify/assert" @@ -34,6 +35,13 @@ const ( withTag = "this is a simple status that uses hashtag #welcome!" withTagExpected = "<p>this is a simple status that uses hashtag <a href=\"http://localhost:8080/tags/welcome\" class=\"mention hashtag\" rel=\"tag nofollow noreferrer noopener\" target=\"_blank\">#<span>welcome</span></a>!</p>" + + moreComplex = `Another test @foss_satan@fossbros-anonymous.io + +#Hashtag + +Text` + moreComplexExpected = `<p>Another test <span class="h-card"><a href="http://fossbros-anonymous.io/@foss_satan" class="u-url mention" rel="nofollow noreferrer noopener" target="_blank">@<span>foss_satan</span></a></span><br/><br/><a href="http://localhost:8080/tags/Hashtag" class="mention hashtag" rel="tag nofollow noreferrer noopener" target="_blank">#<span>Hashtag</span></a><br/><br/>Text</p>` ) type PlainTestSuite struct { @@ -49,6 +57,7 @@ func (suite *PlainTestSuite) SetupSuite() { suite.testAttachments = testrig.NewTestAttachments() suite.testStatuses = testrig.NewTestStatuses() suite.testTags = testrig.NewTestTags() + suite.testMentions = testrig.NewTestMentions() } func (suite *PlainTestSuite) SetupTest() { @@ -79,6 +88,23 @@ func (suite *PlainTestSuite) TestParseWithTag() { assert.Equal(suite.T(), withTagExpected, f) } +func (suite *PlainTestSuite) TestParseMoreComplex() { + + foundTags := []*gtsmodel.Tag{ + suite.testTags["Hashtag"], + } + + foundMentions := []*gtsmodel.Mention{ + suite.testMentions["zork_mention_foss_satan"], + } + + f := suite.formatter.FromPlain(moreComplex, foundMentions, foundTags) + + fmt.Println(f) + + assert.Equal(suite.T(), moreComplexExpected, f) +} + func TestPlainTestSuite(t *testing.T) { suite.Run(t, new(PlainTestSuite)) } |