Sha256: b114d442a55482913abb9dd1b2fbb607594b262afc59ffa18545b0d6990c50b2

Contents?: true

Size: 902 Bytes

Versions: 2

Compression:

Stored size: 902 Bytes

Contents

require 'test_helper'

module GraphQL
  module Client
    module Query
      class InlineFragmentTest < Minitest::Test
        def setup
          @schema = GraphQLSchema.new(schema_fixture('schema.json'))
          @document = Document.new(@schema)
        end

        def test_resolver_type_is_the_type
          shop = @schema.type('Shop')
          inline_fragment = InlineFragment.new(shop, document: @document)

          assert_equal shop, inline_fragment.resolver_type
        end

        def test_to_query
          shop = @schema.type('Shop')

          inline_fragment = InlineFragment.new(shop, document: @document) do |f|
            f.add_field('name')
          end

          query_string = <<~QUERY
            ... on Shop {
              name
            }
          QUERY

          assert_equal query_string.chomp, inline_fragment.to_query
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
graphql_client-0.4.1 test/graphql_client/query/inline_fragment_test.rb
graphql_client-0.3.3 test/graphql_client/query/inline_fragment_test.rb