diff options
author | Ivan Tashkinov <ivant.business@gmail.com> | 2019-04-04 23:43:08 +0300 |
---|---|---|
committer | Ivan Tashkinov <ivant.business@gmail.com> | 2019-04-04 23:43:08 +0300 |
commit | 45765918c377c6daf8ee8e5bfad4ea24f67766b6 (patch) | |
tree | a8ccea9436d7c533a481939a4724c62d8ffac4c0 /test/web/common_api/common_api_utils_test.exs | |
parent | f7cd9131d4aa0da3c4c0174acc56ce1bbdbd284c (diff) | |
parent | 9c9eec62c2fb67507708dd9e5d3f80a098881a6e (diff) | |
download | pleroma-45765918c377c6daf8ee8e5bfad4ea24f67766b6.tar.gz |
[#923] Merge remote-tracking branch 'remotes/upstream/develop' into twitter_oauth
# Conflicts:
# mix.exs
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 |