diff options
Diffstat (limited to 'spec/support_specs/helpers/graphql_helpers_spec.rb')
-rw-r--r-- | spec/support_specs/helpers/graphql_helpers_spec.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/support_specs/helpers/graphql_helpers_spec.rb b/spec/support_specs/helpers/graphql_helpers_spec.rb index a9fe5b8d196..fae29ec32f5 100644 --- a/spec/support_specs/helpers/graphql_helpers_spec.rb +++ b/spec/support_specs/helpers/graphql_helpers_spec.rb @@ -43,6 +43,21 @@ RSpec.describe GraphqlHelpers do expect(graphql_dig_at(data, :foo, :nodes, :bar, :nodes, :id)).to eq([1, 2, 3, 4]) end + + it 'does not omit nils at the leaves' do + data = { + 'foo' => { + 'nodes' => [ + { 'bar' => { 'nodes' => [{ 'id' => nil }, { 'id' => 2 }] } }, + { 'bar' => { 'nodes' => [{ 'id' => 3 }, { 'id' => nil }] } }, + { 'bar' => nil } + ] + }, + 'irrelevant' => 'the field is a red-herring' + } + + expect(graphql_dig_at(data, :foo, :nodes, :bar, :nodes, :id)).to eq([nil, 2, 3, nil]) + end end describe 'var' do |