defmodule ParserTest do use ExUnit.Case 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" => %{ "name" => ["First Note"], "content" => ["Hello World!"], "category" => ["Foo", "Bar"] } } assert {:ok, "entry", %{ "content" => ["Hello World!"], "category" => ["Foo", "Bar"], "name" => ["First Note"] }} == parse_create_body("application/json", params) end 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