aboutsummaryrefslogtreecommitdiff
path: root/test/web/common_api/common_api_utils_test.exs
diff options
context:
space:
mode:
authorAlex S <alex.strizhakov@gmail.com>2019-04-06 20:34:00 +0700
committerAlex S <alex.strizhakov@gmail.com>2019-04-06 20:34:00 +0700
commit7410aee886fbb38615bb595b8b7be0722761a0a4 (patch)
tree26372ac184398430a0a18f3285dba2b543632fb0 /test/web/common_api/common_api_utils_test.exs
parentfa8483cb808ef4b8b907d7ec0eeb882f3f47d927 (diff)
parent3c5daa0235aaf47eeeda557fd677e3604cb7d701 (diff)
downloadpleroma-7410aee886fbb38615bb595b8b7be0722761a0a4.tar.gz
Merge develop to 770-add-emoji-tags
Merge conflict in test/web/mastodon_api/mastodon_api_controller_test.exs
Diffstat (limited to 'test/web/common_api/common_api_utils_test.exs')
-rw-r--r--test/web/common_api/common_api_utils_test.exs36
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