2024-12-05 14:36:18 +00:00
|
|
|
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)
|
2024-12-05 14:36:18 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
test "parse/1 identifies a bookmark" do
|
|
|
|
props = %{
|
2024-12-06 08:40:16 +00:00
|
|
|
"content" => ["100 Rabbits"],
|
2024-12-05 14:36:18 +00:00
|
|
|
"bookmark-of" => ["https://100r.co"]
|
|
|
|
}
|
|
|
|
|
|
|
|
assert {:ok,
|
|
|
|
%PlugIndie.Post{
|
|
|
|
type: :bookmark,
|
2024-12-06 08:40:16 +00:00
|
|
|
content: "100 Rabbits",
|
2024-12-05 14:36:18 +00:00
|
|
|
bookmark_of: "https://100r.co"
|
2024-12-06 08:40:16 +00:00
|
|
|
}} = parse(props)
|
2024-12-05 14:36:18 +00:00
|
|
|
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)
|
2024-12-05 14:36:18 +00:00
|
|
|
end
|
|
|
|
end
|