Update eblurhash to a non-bugged version (#34)
[akkoma] / test / pleroma / upload / filter / analyze_metadata_test.exs
index 488743952744101e16dc37bae6eb2c628878b86e..10f9828c4a473de55c65a08168b0311d58706df0 100644 (file)
@@ -6,7 +6,7 @@ defmodule Pleroma.Upload.Filter.AnalyzeMetadataTest do
   use Pleroma.DataCase, async: true
   alias Pleroma.Upload.Filter.AnalyzeMetadata
 
-  test "adds the image dimensions" do
+  test "adds the dimensions and blurhash for images" do
     upload = %Pleroma.Upload{
       name: "an… image.jpg",
       content_type: "image/jpeg",
@@ -14,10 +14,15 @@ defmodule Pleroma.Upload.Filter.AnalyzeMetadataTest do
       tempfile: Path.absname("test/fixtures/image.jpg")
     }
 
-    assert {:ok, :filtered, %{width: 1024, height: 768}} = AnalyzeMetadata.filter(upload)
+    {:ok, :filtered, meta} = AnalyzeMetadata.filter(upload)
+
+    assert %{width: 1024, height: 768} = meta
+    assert meta.blurhash
+    # Blurhashes should be a valid base83 string
+    assert meta.blurhash =~ ~r/^[A-Za-z0-9#$%*\+,-\.:;=\?@\[\]\^_{|}~]{6,}$/
   end
 
-  test "adds the video dimensions" do
+  test "adds the dimensions for videos" do
     upload = %Pleroma.Upload{
       name: "coolvideo.mp4",
       content_type: "video/mp4",