Fixes #415. Properly handle nil and empty string by User.parse_bio
[akkoma] / test / web / twitter_api / twitter_api_test.exs
index 76de68783260dcaa912eaf911989b9508f2d52c1..522cfd11d182a98327dc0041a510f3e336c417d4 100644 (file)
@@ -182,13 +182,15 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
   end
 
   test "upload a file" do
+    user = insert(:user)
+
     file = %Plug.Upload{
       content_type: "image/jpg",
       path: Path.absname("test/fixtures/image.jpg"),
       filename: "an_image.jpg"
     }
 
-    response = TwitterAPI.upload(file)
+    response = TwitterAPI.upload(file, user)
 
     assert is_binary(response)
   end
@@ -244,7 +246,24 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
       "nickname" => "lain",
       "email" => "lain@wired.jp",
       "fullname" => "lain iwakura",
-      "bio" => "close the world.",
+      "password" => "bear",
+      "confirm" => "bear"
+    }
+
+    {:ok, user} = TwitterAPI.register_user(data)
+
+    fetched_user = Repo.get_by(User, nickname: "lain")
+
+    assert UserView.render("show.json", %{user: user}) ==
+             UserView.render("show.json", %{user: fetched_user})
+  end
+
+  test "it registers a new user with empty string in bio and returns the user." do
+    data = %{
+      "nickname" => "lain",
+      "email" => "lain@wired.jp",
+      "fullname" => "lain iwakura",
+      "bio" => "",
       "password" => "bear",
       "confirm" => "bear"
     }