1
0
Fork 0
mirror of https://framagit.org/framasoft/mobilizon.git synced 2024-12-22 16:03:25 +00:00
mobilizon/test/service/export/icalendar_test.exs
2020-01-28 20:15:59 +01:00

39 lines
1.2 KiB
Elixir

defmodule Mobilizon.Service.ICalendarTest do
use Mobilizon.DataCase
import Mobilizon.Factory
alias ICalendar.Value
alias Mobilizon.Addresses.Address
alias Mobilizon.Events.Event
alias Mobilizon.Service.Export.ICalendar, as: ICalendarService
describe "export an event to ics" do
test "export basic infos" do
%Event{} = event = insert(:event)
ics = """
BEGIN:VCALENDAR
CALSCALE:GREGORIAN
VERSION:2.0
PRODID:-//ICalendar//Mobilizon//EN
BEGIN:VEVENT
CATEGORIES:#{event.tags |> Enum.map(& &1.title) |> Enum.join(",")}
DESCRIPTION:Ceci est une description avec une première phrase assez longue\\,\\n puis sur une seconde ligne
DTEND:#{Value.to_ics(event.ends_on)}
DTSTAMP:#{Value.to_ics(event.publish_at)}
DTSTART:#{Value.to_ics(event.begins_on)}
GEO:#{event.physical_address |> Address.coords() |> Tuple.to_list() |> Enum.join(";")}
LOCATION:#{Address.representation(event.physical_address)}
SUMMARY:#{event.title}
UID:#{event.uuid}
URL:#{event.url}
END:VEVENT
END:VCALENDAR
"""
assert {:ok, ics} == ICalendarService.export_public_event(event)
end
end
end