status-go/protocol/urls/urls_test.go

33 lines
990 B
Go
Raw Normal View History

2020-10-27 17:35:28 +00:00
package urls
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestGetLinkPreviewData(t *testing.T) {
statusTownhall := LinkPreviewData{
Site: "YouTube",
Title: "Status Town Hall #67 - 12 October 2020",
ThumbnailURL: "https://i.ytimg.com/vi/mzOyYtfXkb0/hqdefault.jpg",
}
previewData, err := GetLinkPreviewData("https://www.youtube.com/watch?v=mzOyYtfXkb0")
require.NoError(t, err)
require.Equal(t, statusTownhall.Site, previewData.Site)
require.Equal(t, statusTownhall.Title, previewData.Title)
require.Equal(t, statusTownhall.ThumbnailURL, previewData.ThumbnailURL)
previewData, err = GetLinkPreviewData("https://youtu.be/mzOyYtfXkb0")
require.NoError(t, err)
require.Equal(t, statusTownhall.Site, previewData.Site)
require.Equal(t, statusTownhall.Title, previewData.Title)
require.Equal(t, statusTownhall.ThumbnailURL, previewData.ThumbnailURL)
_, err = GetLinkPreviewData("https://www.test.com/unknown")
require.Error(t, err)
}