Sha256: b64d1e5234c226626ebbbbd0f812e2999de9c0b6c491962b0b10ed46af49a6cf

Contents?: true

Size: 1.08 KB

Versions: 12

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true
require "spec_helper"

describe GraphQL::Language::Nodes::AbstractNode do
  describe "child and scalar attributes" do
    it "are inherited by node subclasses" do
      subclassed_directive = Class.new(GraphQL::Language::Nodes::Directive)

      assert_equal GraphQL::Language::Nodes::Directive.scalar_attributes,
        subclassed_directive.scalar_attributes

      assert_equal GraphQL::Language::Nodes::Directive.child_attributes,
        subclassed_directive.child_attributes
    end
  end

  describe "#filename" do
    it "is set after .parse_file" do
      filename = "spec/support/parser/filename_example.graphql"
      doc = GraphQL.parse_file(filename)
      op = doc.definitions.first
      field = op.selections.first
      arg = field.arguments.first

      assert_equal filename, doc.filename
      assert_equal filename, op.filename
      assert_equal filename, field.filename
      assert_equal filename, arg.filename
    end

    it "is null when parse from string" do
      doc = GraphQL.parse("{ thing }")
      assert_nil doc.filename
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
graphql-1.8.0.pre2 spec/graphql/language/nodes_spec.rb
graphql-1.7.7 spec/graphql/language/nodes_spec.rb
graphql-1.8.0.pre1 spec/graphql/language/nodes_spec.rb
graphql-1.7.6 spec/graphql/language/nodes_spec.rb
graphql-1.7.5 spec/graphql/language/nodes_spec.rb
graphql-1.7.4 spec/graphql/language/nodes_spec.rb
graphql-1.7.3 spec/graphql/language/nodes_spec.rb
graphql-1.7.2 spec/graphql/language/nodes_spec.rb
graphql-1.7.1 spec/graphql/language/nodes_spec.rb
graphql-1.7.0 spec/graphql/language/nodes_spec.rb
graphql-1.6.8 spec/graphql/language/nodes_spec.rb
graphql-1.6.7 spec/graphql/language/nodes_spec.rb