Skip to content

Commit

Permalink
[tests] Add more tests to strip_unset_booleans/3
Browse files Browse the repository at this point in the history
  • Loading branch information
cpjolicoeur committed May 19, 2023
1 parent bb5dd25 commit aff42c3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/torch/helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ defmodule Torch.Helpers do
iex> strip_unset_booleans(%{"post" => %{"title_contains" => "foo"}}, "post", [])
%{"post" => %{"title_contains" => "foo"}}
iex> strip_unset_booleans(%{"post" => %{"title_contains" => "foo"}}, "post", [:title])
%{"post" => %{"title_contains" => "foo"}}
iex> strip_unset_booleans(%{"post" => %{"title_equals" => "true"}}, "post", [:title])
%{"post" => %{"title_equals" => "true"}}
Expand All @@ -90,6 +93,12 @@ defmodule Torch.Helpers do
iex> strip_unset_booleans(%{"post" => %{"name_contains" => "foo", "title_equals" => "any"}}, "post", [:title])
%{"post" => %{"name_contains" => "foo"}}
iex> strip_unset_booleans(%{"post" => %{"name_equals" => "any", "title_equals" => "any"}}, "post", [:title, :name])
%{"post" => %{}}
iex> strip_unset_booleans(%{"post" => %{"name_equals" => "any", "title_equals" => "any", "surname_equals" => "bar"}}, "post", [:title, :name])
%{"post" => %{"surname_equals" => "bar"}}
"""
@spec strip_unset_booleans(params, binary, [atom]) :: params
def strip_unset_booleans(params, _, []), do: params
Expand Down

0 comments on commit aff42c3

Please sign in to comment.