-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,23 @@ | ||
defmodule Sassone.BuilderTest do | ||
use ExUnit.Case, async: true | ||
|
||
alias Sassone.Builder | ||
alias Sassone.TestSchemas.Person | ||
|
||
describe "building" do | ||
test "encode simple schema" do | ||
assert ~s|<person gender="female">Alice</person>| = | ||
Builder.build(%Person{gender: "female", name: "Alice"}) | ||
|> Sassone.encode!() | ||
end | ||
|
||
test "decode simple schema" do | ||
Check failure on line 14 in test/sassone/builder_test.exs GitHub Actions / Test (1.12.x/24.x)
Check failure on line 14 in test/sassone/builder_test.exs GitHub Actions / Test (1.13.x/24.x)
Check failure on line 14 in test/sassone/builder_test.exs GitHub Actions / Test (1.14.x/24.x)
Check failure on line 14 in test/sassone/builder_test.exs GitHub Actions / Test (1.15.x/24.x)
Check failure on line 14 in test/sassone/builder_test.exs GitHub Actions / Test (1.16.x/24.x)
Check failure on line 14 in test/sassone/builder_test.exs GitHub Actions / Test (1.14.x/25.x)
Check failure on line 14 in test/sassone/builder_test.exs GitHub Actions / Test (1.15.x/25.x)
Check failure on line 14 in test/sassone/builder_test.exs GitHub Actions / Test (1.16.x/25.x)
Check failure on line 14 in test/sassone/builder_test.exs GitHub Actions / Test (1.17.x/25.x)
Check failure on line 14 in test/sassone/builder_test.exs GitHub Actions / Test (1.14.x/26.x)
Check failure on line 14 in test/sassone/builder_test.exs GitHub Actions / Test (1.15.x/26.x)
Check failure on line 14 in test/sassone/builder_test.exs GitHub Actions / Test (1.16.x/26.x)
Check failure on line 14 in test/sassone/builder_test.exs GitHub Actions / Test (1.17.x/26.x)
|
||
assert {:ok, {Person, %{gender: "female", name: "Alice"}}} = | ||
Sassone.parse_string( | ||
~s|<person gender="female">Alice</person>|, | ||
Builder.handler(%Person{}), | ||
nil | ||
) | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
defmodule Sassone.TestSchemas do | ||
@moduledoc false | ||
|
||
defmodule Person do | ||
@derive { | ||
Sassone.Builder, | ||
case: :snake, | ||
debug: true, | ||
root_element: "person", | ||
fields: [gender: [type: :attribute], name: [type: :content]] | ||
} | ||
defstruct [:gender, :name] | ||
end | ||
end |