push_subscription_view_test.exs (789B)
1 # Pleroma: A lightweight social networking server 2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/> 3 # SPDX-License-Identifier: AGPL-3.0-only 4 5 defmodule Pleroma.Web.MastodonAPI.PushSubscriptionViewTest do 6 use Pleroma.DataCase 7 import Pleroma.Factory 8 alias Pleroma.Web.MastodonAPI.PushSubscriptionView, as: View 9 alias Pleroma.Web.Push 10 11 test "Represent a subscription" do 12 subscription = insert(:push_subscription, data: %{"alerts" => %{"mention" => true}}) 13 14 expected = %{ 15 alerts: %{"mention" => true}, 16 endpoint: subscription.endpoint, 17 id: to_string(subscription.id), 18 server_key: Keyword.get(Push.vapid_config(), :public_key) 19 } 20 21 assert expected == View.render("push_subscription.json", %{subscription: subscription}) 22 end 23 end