Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/outstanding/map.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ defoutstanding expected :: Map, actual :: Any do
case Outstand.type_of(actual) do
Map ->
Map.keys(expected)
|> Enum.filter(&(Outstanding.outstanding(expected[&1], actual[&1])))
|> Enum.filter(fn key ->
not Map.has_key?(actual, key) or
Outstanding.outstanding(expected[key], actual[key]) != nil
end)
|> Enum.into(%{}, &{&1, Outstanding.outstanding(expected[&1], actual[&1])})
|> Outstand.suppress()

_ ->
expected
end
end
end
6 changes: 5 additions & 1 deletion test/map_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ defmodule Outstanding.MapTest do

gen_something_outstanding_test("key outstanding", %{x: :a, y: :b}, %{x: :a, z: :b})
gen_something_outstanding_test("value outstanding", %{x: :a, y: :b}, %{x: :b, y: :b})
gen_something_outstanding_test("key nil value outstanding", %{x: :a, y: nil}, %{x: :a, z: :b})
gen_something_outstanding_test("value falsy outstanding", %{x: false, y: :b}, %{x: :b, y: :b})
gen_nothing_outstanding_test("realized", %{x: :a, y: :b}, %{x: :a, y: :b})
gen_nothing_outstanding_test("realized with extra item", %{x: :a, y: :b}, %{x: :a, y: :b, z: :b})
gen_result_outstanding_test("key result", %{x: :a, y: :b}, %{x: :a, z: :b}, %{y: :b})
gen_result_outstanding_test("value result", %{x: :a, y: :b}, %{x: :b, y: :b}, %{x: :a})
gen_result_outstanding_test("value result", %{x: :a, y: :b}, %{x: :b, y: :b}, %{x: :a})
gen_result_outstanding_test("key nil result", %{x: :a, y: nil}, %{x: :a, z: :b}, %{y: nil})
gen_result_outstanding_test("value falsy result", %{x: false, y: :b}, %{x: :b, y: :b}, %{x: false})
end