plug_indie/test/properties_test.exs

58 lines
1.2 KiB
Elixir
Raw Permalink Normal View History

defmodule PropertiesTest do
use ExUnit.Case
doctest PlugIndie.Properties
import PlugIndie.Properties, only: [parse: 1]
test "parse/1 identifies a note" do
props = %{
"content" => ["Hello World!"]
}
assert {:ok,
%PlugIndie.Post{
type: :note,
content: "Hello World!"
2024-12-06 08:40:16 +00:00
}} = parse(props)
end
test "parse/1 identifies an article" do
props = %{
"name" => ["My Title"],
"content" => ["Hello World!"]
}
assert {:ok,
%PlugIndie.Post{
type: :article,
content: "Hello World!",
title: "My Title"
}} = parse(props)
end
test "parse/1 identifies a bookmark" do
props = %{
2024-12-06 08:40:16 +00:00
"content" => ["100 Rabbits"],
"bookmark-of" => ["https://100r.co"]
}
assert {:ok,
%PlugIndie.Post{
type: :bookmark,
2024-12-06 08:40:16 +00:00
content: "100 Rabbits",
bookmark_of: "https://100r.co"
2024-12-06 08:40:16 +00:00
}} = parse(props)
end
test "parse/1 identifies a like" do
props = %{
"like-of" => ["https://100r.co"]
}
assert {:ok,
%PlugIndie.Post{
type: :like,
like_of: "https://100r.co"
2024-12-06 08:40:16 +00:00
}} = parse(props)
end
end