Sha256: eaf39132542aa2fec299f92735ef479bf659f6cca99f44713a0502b89816f3ee
Contents?: true
Size: 1.32 KB
Versions: 26
Compression:
Stored size: 1.32 KB
Contents
# frozen_string_literal: true require "spec_helper" describe GraphQL::Language::Parser do subject { GraphQL::Language::Parser } describe "anonymous fragment extension" do let(:document) { GraphQL.parse(query_string) } let(:query_string) {%| fragment on NestedType @or(something: "ok") { anotherNestedField } |} let(:fragment) { document.definitions.first } it "creates an anonymous fragment definition" do assert fragment.is_a?(GraphQL::Language::Nodes::FragmentDefinition) assert_equal nil, fragment.name assert_equal 1, fragment.selections.length assert_equal "NestedType", fragment.type.name assert_equal 1, fragment.directives.length assert_equal [2, 7], fragment.position end end it "parses empty arguments" do strings = [ "{ field { inner } }", "{ field() { inner }}", ] strings.each do |query_str| doc = subject.parse(query_str) field = doc.definitions.first.selections.first assert_equal 0, field.arguments.length assert_equal 1, field.selections.length end end it "parses the test schema" do schema = Dummy::Schema schema_string = GraphQL::Schema::Printer.print_schema(schema) document = subject.parse(schema_string) assert_equal schema_string, document.to_query_string end end
Version data entries
26 entries across 26 versions & 1 rubygems