Sha256: ad2b9cdd3afdfd3619d7b8642d3165dc48ed1091179d1916bf5a842bf5175d6a

Contents?: true

Size: 1.23 KB

Versions: 3

Compression:

Stored size: 1.23 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, LocalProductInterface], 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

3 entries across 3 versions & 1 rubygems

Version Path
graphql-0.18.5 spec/graphql/object_type_spec.rb
graphql-0.18.4 spec/graphql/object_type_spec.rb
graphql-0.18.3 spec/graphql/object_type_spec.rb