From 329a5e8144eea78e607c8a218ae78ae8f346f2e8 Mon Sep 17 00:00:00 2001 From: Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com> Date: Wed, 11 Aug 2021 16:54:54 +0200 Subject: Text duplication fix (#137) * start testing text duplication * tests * fixes + tests --- internal/text/plain_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'internal/text/plain_test.go') 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 = "

this is a simple status that uses hashtag #welcome!

" + + moreComplex = `Another test @foss_satan@fossbros-anonymous.io + +#Hashtag + +Text` + moreComplexExpected = `

Another test @foss_satan

#Hashtag

Text

` ) 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)) } -- cgit v1.2.3