defmodule Mobilizon.Service.MetadataTest do alias Mobilizon.Actors.Actor alias Mobilizon.Discussions.Comment alias Mobilizon.Events.Event alias Mobilizon.Posts.Post alias Mobilizon.Service.Metadata alias Mobilizon.Tombstone alias Mobilizon.Web.Endpoint alias Mobilizon.Web.Router.Helpers, as: Routes use Mobilizon.DataCase import Mobilizon.Factory describe "build_tags/2 for an actor" do test "that is a group gives tags" do %Actor{} = group = insert(:group, name: "My group") # {group.name} (@#{group.preferred_username})" property="og:title">" assert group |> Metadata.build_tags() |> Metadata.Utils.stringify_tags() == "" assert group |> Map.put(:avatar, nil) |> Metadata.build_tags() |> Metadata.Utils.stringify_tags() == " Metadata.build_tags() |> Metadata.Utils.stringify_tags() == "" assert person |> Metadata.build_tags("fr") |> Metadata.Utils.stringify_tags() == "" end end describe "build_tags/2 for an event" do test "gives tags" do alias Mobilizon.Web.Endpoint %Event{} = event = insert(:event) # Because the description in Schema.org data is double-escaped a = "\n" b = "\\n" assert event |> Metadata.build_tags() |> Metadata.Utils.stringify_tags() == """