Support validation for inline OpenAPI schema and automatic tests for examples
[akkoma] / test / web / mastodon_api / controllers / custom_emoji_controller_test.exs
index 6567a06678396766e372435ecb045ebf6c8c3802..4222556a422c3d14272fd1dc0450119b7d442ce8 100644 (file)
@@ -4,13 +4,16 @@
 
 defmodule Pleroma.Web.MastodonAPI.CustomEmojiControllerTest do
   use Pleroma.Web.ConnCase, async: true
+  alias Pleroma.Web.ApiSpec
+  import OpenApiSpex.TestAssertions
 
   test "with tags", %{conn: conn} do
-    [emoji | _body] =
-      conn
-      |> get("/api/v1/custom_emojis")
-      |> json_response(200)
+    assert resp =
+             conn
+             |> get("/api/v1/custom_emojis")
+             |> json_response_and_validate_schema(200)
 
+    assert [emoji | _body] = resp
     assert Map.has_key?(emoji, "shortcode")
     assert Map.has_key?(emoji, "static_url")
     assert Map.has_key?(emoji, "tags")
@@ -18,5 +21,6 @@ defmodule Pleroma.Web.MastodonAPI.CustomEmojiControllerTest do
     assert Map.has_key?(emoji, "category")
     assert Map.has_key?(emoji, "url")
     assert Map.has_key?(emoji, "visible_in_picker")
+    assert_schema(emoji, "CustomEmoji", ApiSpec.spec())
   end
 end