plug_indie/test/parser_test.exs

43 lines
1.1 KiB
Elixir
Raw Permalink Normal View History

defmodule ParserTest do
use ExUnit.Case
2024-11-29 09:42:27 +00:00
doctest PlugIndie.Parser
import PlugIndie.Parser, only: [parse_create_body: 2]
test "parse_create_body with content-type json" do
params = %{
"type" => ["h-entry"],
"properties" => %{
2024-12-05 14:36:43 +00:00
"name" => ["First Note"],
"content" => ["Hello World!"],
"category" => ["Foo", "Bar"]
}
}
2024-12-05 14:36:43 +00:00
assert {:ok, "entry",
%{
"content" => ["Hello World!"],
"category" => ["Foo", "Bar"],
"name" => ["First Note"]
}} ==
parse_create_body("application/json", params)
end
2024-12-05 14:36:43 +00:00
test "parse_create_body with content-type form" do
params = %{
"h" => "entry",
"name" => "First Note",
"content" => "Hello World!",
"category" => ["Foo", "Bar"]
}
# TODO: fix content type
assert {:ok, "entry",
%{
"content" => ["Hello World!"],
"category" => ["Foo", "Bar"],
"name" => ["First Note"]
}} ==
parse_create_body("application/form", params)
end
end