plug_indie/test/properties_test.exs

57 lines
1.2 KiB
Elixir

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!"
}} = 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 = %{
"content" => ["100 Rabbits"],
"bookmark-of" => ["https://100r.co"]
}
assert {:ok,
%PlugIndie.Post{
type: :bookmark,
content: "100 Rabbits",
bookmark_of: "https://100r.co"
}} = 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"
}} = parse(props)
end
end