diff options
author | lain <lain@soykaf.club> | 2019-04-08 14:10:51 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2019-04-08 14:10:51 +0200 |
commit | a9f805c87100fd2ee1d8426460b81af4a235d574 (patch) | |
tree | 70179175f0ff84f3f4c7399f63694766aaa65b35 /test/web/common_api/common_api_utils_test.exs | |
parent | 5d871173d189a0019fda0ee76f8a324d90a163ee (diff) | |
parent | 4977e96fa408e8148a355b3c759af34ae3ca312d (diff) | |
download | pleroma-a9f805c87100fd2ee1d8426460b81af4a235d574.tar.gz |
Merge remote-tracking branch 'origin/develop' into features/mastoapi/2.6.0-conversations
Diffstat (limited to 'test/web/common_api/common_api_utils_test.exs')
-rw-r--r-- | test/web/common_api/common_api_utils_test.exs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/web/common_api/common_api_utils_test.exs b/test/web/common_api/common_api_utils_test.exs index e04b9f9b5..f0c59d5c3 100644 --- a/test/web/common_api/common_api_utils_test.exs +++ b/test/web/common_api/common_api_utils_test.exs @@ -153,4 +153,40 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do assert conversation_id == object.id end end + + describe "formats date to asctime" do + test "when date is in ISO 8601 format" do + date = DateTime.utc_now() |> DateTime.to_iso8601() + + expected = + date + |> DateTime.from_iso8601() + |> elem(1) + |> Calendar.Strftime.strftime!("%a %b %d %H:%M:%S %z %Y") + + assert Utils.date_to_asctime(date) == expected + end + + test "when date is a binary in wrong format" do + date = DateTime.utc_now() + + expected = "" + + assert Utils.date_to_asctime(date) == expected + end + + test "when date is a Unix timestamp" do + date = DateTime.utc_now() |> DateTime.to_unix() + + expected = "" + + assert Utils.date_to_asctime(date) == expected + end + + test "when date is nil" do + expected = "" + + assert Utils.date_to_asctime(nil) == expected + end + end end |