Sha256: 28149ed04fad4543fb2a0f946907226c8d9012d3dd42141e78f979256694f000

Contents?: true

Size: 1.21 KB

Versions: 16

Compression:

Stored size: 1.21 KB

Contents

require "spec_helper"

describe GraphQL::ObjectType do
  let(:type) { CheeseType }

  it "has a name" do
    assert_equal("Cheese", type.name)
    type.name = "Fromage"
    assert_equal("Fromage", type.name)
    type.name = "Cheese"
  end

  it "has a description" do
    assert_equal(22, type.description.length)
  end

  it "may have interfaces" do
    assert_equal([EdibleInterface, AnimalProductInterface], type.interfaces)
  end

  describe '#get_field ' do
    it "exposes fields" do
      field = type.get_field("id")
      assert_equal(GraphQL::TypeKinds::NON_NULL, field.type.kind)
      assert_equal(GraphQL::TypeKinds::SCALAR, field.type.of_type.kind)
    end

    it "exposes defined field property" do
      field_without_prop = CheeseType.get_field("flavor")
      field_with_prop = CheeseType.get_field("fatContent")
      assert_equal(field_without_prop.property, nil)
      assert_equal(field_with_prop.property, :fat_content)
    end

    it "looks up from interfaces" do
      field_from_self = CheeseType.get_field("fatContent")
      field_from_iface = MilkType.get_field("fatContent")
      assert_equal(field_from_self.property, :fat_content)
      assert_equal(field_from_iface.property, nil)
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
graphql-0.18.2 spec/graphql/object_type_spec.rb
graphql-0.18.1 spec/graphql/object_type_spec.rb
graphql-0.18.0 spec/graphql/object_type_spec.rb
graphql-0.17.2 spec/graphql/object_type_spec.rb
graphql-0.17.1 spec/graphql/object_type_spec.rb
graphql-0.17.0 spec/graphql/object_type_spec.rb
graphql-0.16.1 spec/graphql/object_type_spec.rb
graphql-0.16.0 spec/graphql/object_type_spec.rb
graphql-0.15.3 spec/graphql/object_type_spec.rb
graphql-0.15.2 spec/graphql/object_type_spec.rb
graphql-0.14.2 spec/graphql/object_type_spec.rb
graphql-0.15.1 spec/graphql/object_type_spec.rb
graphql-0.15.0 spec/graphql/object_type_spec.rb
graphql-0.14.1 spec/graphql/object_type_spec.rb
graphql-0.14.0 spec/graphql/object_type_spec.rb
graphql-0.13.0 spec/graphql/object_type_spec.rb