tests: add tests for Object.normalize()
authorWilliam Pitcock <nenolod@dereferenced.org>
Tue, 4 Dec 2018 05:00:11 +0000 (05:00 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Tue, 4 Dec 2018 05:00:11 +0000 (05:00 +0000)
test/object_test.exs

index 909605560e6d8015b41e2eb38b583346f51da952..3907748f76f662757b4c6e8a4ea5baed8f563ad3 100644 (file)
@@ -49,4 +49,22 @@ defmodule Pleroma.ObjectTest do
       refute object == cached_object
     end
   end
+
+  describe "normalizer" do
+    test "fetches unknown objects by default" do
+      %Object{} = object = Object.normalize("http://mastodon.example.org/@admin/99541947525187367")
+
+      assert object.data["url"] == "http://mastodon.example.org/@admin/99541947525187367"
+    end
+
+    test "fetches unknown objects when fetch_remote is explicitly true" do
+      %Object{} = object = Object.normalize("http://mastodon.example.org/@admin/99541947525187367", true)
+
+      assert object.data["url"] == "http://mastodon.example.org/@admin/99541947525187367"
+    end
+
+    test "does not fetch unknown objects when fetch_remote is false" do
+      assert is_nil(Object.normalize("http://mastodon.example.org/@admin/99541947525187367", false))
+    end
+  end
 end