Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the test helpers compatible with nested fields #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

niels
Copy link

@niels niels commented Apr 10, 2021

Previously, a GraphQL document containing nested fields could not be tested if one of the values was null / nil. The library stringifies the expected response, coercing nil to "". The assert_values_match was not able to take into account the field being defined as nillable because it wasn't aware of the nesting. This led to the below mismatch:

  1) test assert_equivalent_graphql/3 nested fields compare (AbsintheErrorPayload.TestHelperTest)
     test/test_helper_test.exs:131
     Assertion with == failed
     code:  assert {field, expected} == {field, response}
     left:  {
              :single,
              %{
                "integer" => "1",
                "nillable" => "",
                "string" => "single nested string"
              }
            }
     right: {
              :single,
              %{
                "integer" => 1,
                "nillable" => nil,
                "string" => "single nested string"
              }
            }
     stacktrace:
       (elixir 1.11.3) lib/enum.ex:798: Enum."-each/2-lists^foreach/1-0-"/2
       test/test_helper_test.exs:132: (test)

This PR adds a new assert_values_match so that nested field definitions get recursively resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant