1 defmodule Pleroma.Web.EmojiAPI.EmojiAPIControllerTest do
2 use Pleroma.Web.ConnCase
8 test "shared & non-shared pack information in list_packs is ok" do
10 resp = conn |> get(emoji_api_path(conn, :list_packs)) |> json_response(200)
12 assert Map.has_key?(resp, "test_pack")
14 pack = resp["test_pack"]
16 assert Map.has_key?(pack["pack"], "download-sha256")
17 assert pack["pack"]["can-download"]
19 assert pack["files"] == %{"blank" => "blank.png"}
23 assert Map.has_key?(resp, "test_pack_nonshared")
25 pack = resp["test_pack_nonshared"]
27 refute pack["pack"]["shared"]
28 refute pack["pack"]["can-download"]
31 test "downloading a shared pack from download_shared" do
36 |> get(emoji_api_path(conn, :download_shared, "test_pack"))
39 {:ok, arch} = :zip.unzip(resp, [:memory])
41 assert Enum.find(arch, fn {n, _} -> n == 'pack.yml' end)
42 assert Enum.find(arch, fn {n, _} -> n == 'blank.png' end)
45 test "downloading a shared pack from another instance via download_from" do
47 File.rm_rf!("test/instance_static/emoji/test_pack2")
53 url: "https://example.com/api/pleroma/emoji/packs/list"
58 |> get(emoji_api_path(conn, :list_packs))
64 url: "https://example.com/api/pleroma/emoji/packs/download_shared/test_pack"
69 |> get(emoji_api_path(conn, :download_shared, "test_pack"))
74 admin = insert(:user, info: %{is_admin: true})
79 |> put_req_header("content-type", "application/json")
80 |> assign(:user, admin)
87 instance_address: "https://example.com",
88 pack_name: "test_pack",
93 |> text_response(200) == "ok"
95 assert File.exists?("test/instance_static/emoji/test_pack2/pack.yml")
96 assert File.exists?("test/instance_static/emoji/test_pack2/blank.png")