diff --git a/internal/processing/status/create_test.go b/internal/processing/status/create_test.go index 1199642b6..1010fe78f 100644 --- a/internal/processing/status/create_test.go +++ b/internal/processing/status/create_test.go @@ -19,6 +19,9 @@ package status_test import ( "context" + "fmt" + "net/http" + "net/http/httptest" "testing" "github.com/stretchr/testify/suite" @@ -241,6 +244,47 @@ func (suite *StatusCreateTestSuite) TestProcessNoContentTypeUsesDefault() { suite.Equal(apimodel.StatusContentTypeDefault, apiStatus.ContentType) } +func (suite *StatusCreateTestSuite) TestProcessPreview() { + ctx := context.Background() + creatingAccount := suite.testAccounts["local_account_1"] + creatingApplication := suite.testApplications["application_1"] + + httpServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + const body = ` + + +The Rock (1996) + + + + + + +` + + _, err := w.Write([]byte(body)) + suite.NoError(err) + })) + defer httpServer.Close() + + statusCreateForm := &apimodel.StatusCreateRequest{ + Status: fmt.Sprintf("poopoo %s peepee", httpServer.URL), + Visibility: apimodel.VisibilityPublic, + LocalOnly: util.Ptr(false), + Language: "en", + ContentType: apimodel.StatusContentTypePlain, + } + + apiStatus, errWithCode := suite.status.Create(ctx, creatingAccount, creatingApplication, statusCreateForm) + suite.NoError(errWithCode) + suite.NotNil(apiStatus) + + suite.Equal("

poopoo peepee

", apiStatus.Content) + + suite.NotNil(apiStatus.Card) + fmt.Println(apiStatus.Card) +} + func TestStatusCreateTestSuite(t *testing.T) { suite.Run(t, new(StatusCreateTestSuite)) }