소스 검색

tests: add tests for rich media helper functions

tags/v1.1.4
William Pitcock 5 년 전
부모
커밋
d7a278a733
1개의 변경된 파일42개의 추가작업 그리고 0개의 파일을 삭제
  1. +42
    -0
      test/web/rich_media/helpers_test.exs

+ 42
- 0
test/web/rich_media/helpers_test.exs 파일 보기

@@ -0,0 +1,42 @@
defmodule Pleroma.Web.RichMedia.HelpersTest do
use Pleroma.DataCase

alias Pleroma.Web.CommonAPI

import Pleroma.Factory
import Tesla.Mock

setup do
mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
:ok
end

test "refuses to crawl incomplete URLs" do
user = insert(:user)

{:ok, activity} =
CommonAPI.post(user, %{
"status" => "[test](example.com/ogp)",
"content_type" => "text/markdown"
})

assert %{} == Pleroma.Web.RichMedia.Helpers.fetch_data_for_activity(activity)
end

test "crawls valid, complete URLs" do
user = insert(:user)

{:ok, activity} =
CommonAPI.post(user, %{
"status" => "[test](http://example.com/ogp)",
"content_type" => "text/markdown"
})

Pleroma.Config.put([:rich_media, :enabled], true)

assert %{page_url: "http://example.com/ogp", rich_media: _} =
Pleroma.Web.RichMedia.Helpers.fetch_data_for_activity(activity)

Pleroma.Config.put([:rich_media, :enabled], false)
end
end

불러오는 중...
취소
저장