diff --git a/test/epochtalk_server_web/controllers/notification_test.exs b/test/epochtalk_server_web/controllers/notification_test.exs new file mode 100644 index 00000000..f3d59b06 --- /dev/null +++ b/test/epochtalk_server_web/controllers/notification_test.exs @@ -0,0 +1,27 @@ +defmodule Test.EpochtalkServerWeb.Controllers.Notification do + use Test.Support.ConnCase, async: true + alias EpochtalkServer.Models.Notification + + describe "counts/2" do + test "when unauthenticated, returns Unauthorized error", %{conn: conn} do + response = + conn + |> get(Routes.notification_path(conn, :counts)) + |> json_response(401) + + assert response["error"] == "Unauthorized" + assert response["message"] == "No resource found" + end + + @tag :authenticated + test "when authenticated, returns number of notifications user has", %{conn: conn} do + response = + conn + |> get(Routes.notification_path(conn, :counts)) + |> json_response(200) + + assert response["mentions"] == 0 + assert response["message"] == 0 + end + end +end