Merge branch 'develop' into issue/1276
[akkoma] / test / web / mastodon_api / views / marker_view_test.exs
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.MarkerViewTest do
6 use Pleroma.DataCase
7 alias Pleroma.Web.MastodonAPI.MarkerView
8 import Pleroma.Factory
9
10 test "returns markers" do
11 marker1 = insert(:marker, timeline: "notifications", last_read_id: "17", unread_count: 5)
12 marker2 = insert(:marker, timeline: "home", last_read_id: "42")
13
14 assert MarkerView.render("markers.json", %{markers: [marker1, marker2]}) == %{
15 "home" => %{
16 last_read_id: "42",
17 updated_at: NaiveDateTime.to_iso8601(marker2.updated_at),
18 version: 0,
19 pleroma: %{unread_count: 0}
20 },
21 "notifications" => %{
22 last_read_id: "17",
23 updated_at: NaiveDateTime.to_iso8601(marker1.updated_at),
24 version: 0,
25 pleroma: %{unread_count: 5}
26 }
27 }
28 end
29 end